:root {
  color-scheme: light;
  --ink: #17211d;
  --muted: #65706b;
  --paper: #fbfaf6;
  --panel: #ffffff;
  --line: #dfe5dd;
  --sage: #78917d;
  --blue: #315f8f;
  --rose: #b86978;
  --gold: #c39143;
  --shadow: 0 14px 35px rgba(30, 42, 36, 0.12);
}

* {
  box-sizing: border-box;
}

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

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

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 920px);
  margin: 0 auto;
  padding: 18px 14px 32px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.eyebrow,
.date-line {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.6rem, 6vw, 2.8rem);
}

h2 {
  margin-bottom: 8px;
  font-size: 1.22rem;
}

h3 {
  margin-bottom: 6px;
  font-size: 1rem;
}

.icon-button,
.text-button,
.segment,
.tab {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
}

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  place-items: center;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(30, 42, 36, 0.08);
}

.hero-band {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: center;
  margin-bottom: 14px;
  padding: 18px;
  border: 1px solid #d7ded6;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(120, 145, 125, 0.18), rgba(49, 95, 143, 0.08)),
    var(--panel);
  box-shadow: var(--shadow);
}

.hero-band p:last-child {
  margin-bottom: 0;
  color: var(--muted);
}

.score-ring {
  display: grid;
  width: 82px;
  height: 82px;
  place-items: center;
  border: 8px solid rgba(49, 95, 143, 0.18);
  border-top-color: var(--blue);
  border-radius: 50%;
  background: var(--panel);
}

.score-ring span {
  margin-bottom: -18px;
  font-size: 1.12rem;
  font-weight: 800;
}

.score-ring small {
  color: var(--muted);
  font-size: 0.68rem;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin: 0 -2px 12px;
  padding: 8px 2px;
  background: rgba(251, 250, 246, 0.94);
  backdrop-filter: blur(10px);
}

.tab {
  min-height: 42px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 750;
}

.tab.is-active {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.panel {
  display: none;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(30, 42, 36, 0.08);
}

.panel.is-active {
  display: block;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-heading h2 {
  margin-bottom: 0;
}

.text-button {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

.workout-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.text-button.subtle {
  background: #eef2ed;
  color: var(--ink);
}

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

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

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  color: var(--ink);
  padding: 10px 12px;
}

textarea {
  resize: vertical;
}

input[type="range"] {
  min-height: 28px;
  padding: 0;
  accent-color: var(--blue);
}

output {
  width: 34px;
  color: var(--blue);
  font-size: 1.05rem;
  font-weight: 900;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
}

.check-row input {
  width: 22px;
  min-height: 22px;
  accent-color: var(--sage);
}

.workout-fields {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf6;
}

.workout-fields legend {
  padding: 0 6px;
  color: var(--ink);
  font-size: 0.98rem;
  font-weight: 850;
}

.detail-grid {
  display: grid;
  gap: 12px;
}

.segmented {
  display: flex;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.segment {
  min-width: 44px;
  padding: 0 12px;
  min-height: 38px;
  border: 0;
  border-radius: 0;
  font-weight: 900;
}

.segment.is-active {
  background: var(--sage);
  color: #fff;
}

.routine {
  display: none;
}

.routine.is-active {
  display: block;
}

.exercise-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: exercise;
}

.exercise-list li {
  position: relative;
  min-height: 68px;
  padding: 12px 12px 12px 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  counter-increment: exercise;
}

.exercise-list li::before {
  content: counter(exercise);
  position: absolute;
  left: 12px;
  top: 14px;
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  background: rgba(195, 145, 67, 0.18);
  color: #78521a;
  font-weight: 900;
}

.exercise-list strong,
.exercise-list span {
  display: block;
}

.exercise-list span {
  color: var(--muted);
  font-size: 0.9rem;
}

.exercise-fields {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.exercise-fields label {
  font-size: 0.82rem;
}

.exercise-fields input,
.exercise-fields select {
  min-height: 42px;
  background: #fff;
}

.next-workout-banner {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid rgba(49, 95, 143, 0.22);
  border-radius: 8px;
  background: rgba(49, 95, 143, 0.07);
}

.next-workout-banner span {
  color: var(--muted);
  font-size: 0.9rem;
}

.progress-strip {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  padding: 10px;
  border-radius: 8px;
  background: #eef2ed;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 720;
}

.felt-good {
  padding: 8px 0 0;
}

.settings-save {
  margin-top: 12px;
}

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

.guidance {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid rgba(184, 105, 120, 0.28);
  border-radius: 8px;
  background: rgba(184, 105, 120, 0.08);
}

.guidance summary {
  font-weight: 850;
}

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

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.metric-grid article {
  min-height: 92px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.metric-grid span {
  display: block;
  font-size: 1.55rem;
  font-weight: 900;
}

.metric-grid p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.history-card strong {
  display: block;
}

.history-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.history-card .workout-summary {
  color: var(--ink);
  font-weight: 650;
}

.quiet-card {
  background: #f7faf6;
}

.session-meta {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf6;
}

.note-band {
  padding: 14px;
  border-left: 4px solid var(--sage);
  background: #f4f7f2;
}

.note-band + .note-band {
  margin-top: 10px;
}

.note-band p {
  margin-bottom: 0;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 14px;
  bottom: 14px;
  max-width: calc(100vw - 28px);
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 750;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (min-width: 680px) {
  .app-shell {
    padding-top: 28px;
  }

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

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

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

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

  .wide {
    grid-column: 1 / -1;
  }

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

  .panel {
    padding: 20px;
  }
}

@media (max-width: 420px) {
  .tabs {
    grid-template-columns: repeat(2, 1fr);
  }

  .hero-band {
    grid-template-columns: 1fr;
  }

  .score-ring {
    width: 74px;
    height: 74px;
  }
}
