:root {
  color-scheme: light;
  --bg: #f8f3ea;
  --panel: #fffdf8;
  --panel-soft: #f1eadf;
  --ink: #1f2825;
  --muted: #6d716b;
  --line: #ded5c8;
  --line-strong: #cfc2b3;
  --accent: #185f52;
  --accent-strong: #10483e;
  --warn: #8e3f32;
  --gold: #9b7420;
  --blue: #365f72;
  --shadow: 0 1px 0 rgba(59, 45, 31, 0.04), 0 12px 28px rgba(59, 45, 31, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  background-image:
    linear-gradient(rgba(110, 91, 62, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(110, 91, 62, 0.025) 1px, transparent 1px);
  background-size: 22px 22px;
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  letter-spacing: 0;
}

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

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  min-height: 100svh;
  padding: 20px 14px 92px;
}

.workout-shell {
  padding-bottom: calc(112px + env(safe-area-inset-bottom));
}

.topbar {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin: 0 auto 20px;
  max-width: 820px;
}

.workout-duration {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
  margin-top: 4px;
}

.workout-duration span,
.rest-timer {
  font-variant-numeric: tabular-nums;
}

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

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

h1 {
  font-size: 1.85rem;
  line-height: 1.05;
}

h2 {
  font-size: 1.15rem;
  line-height: 1.2;
}

h3 {
  font-size: 1rem;
  line-height: 1.2;
}

.view {
  display: grid;
  gap: 14px;
  margin: 0 auto;
  max-width: 820px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 15px;
}

.section-head,
.row-between {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.stack {
  display: grid;
  gap: 10px;
}

.template-list,
.session-list,
.exercise-list,
.set-list {
  display: grid;
  gap: 10px;
}

.template-card,
.session-card,
.exercise-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 10px;
  padding: 15px;
}

.meta {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
}

.small {
  color: var(--muted);
  font-size: 0.78rem;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  align-items: center;
  background: #edf4ee;
  border: 1px solid #d2e0d5;
  border-radius: 999px;
  color: #245349;
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 700;
  min-height: 26px;
  padding: 4px 9px;
}

.pill.blue {
  background: #edf4f7;
  border-color: #d4e3ea;
  color: var(--blue);
}

.pill.gold {
  background: #f8edd0;
  border-color: #e4d19d;
  color: #7a5b16;
}

.rest-timer {
  white-space: nowrap;
}

.rest-timer.complete {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.template-preview {
  display: grid;
  gap: 7px;
}

.template-preview-row {
  align-items: start;
  color: #303836;
  display: block;
  font-size: 0.9rem;
  line-height: 1.25;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn {
  align-items: center;
  background: #e9dfd1;
  border-radius: 10px;
  color: var(--ink);
  display: inline-flex;
  font-weight: 800;
  justify-content: center;
  min-height: 42px;
  padding: 10px 13px;
  text-decoration: none;
}

.btn.primary {
  background: var(--accent);
  color: white;
}

.btn.danger {
  background: #f4e4df;
  color: var(--warn);
}

.btn.ghost {
  background: rgba(255, 253, 248, 0.56);
  border: 1px solid var(--line);
}

.icon-btn {
  align-items: center;
  background: #e9dfd1;
  border-radius: 10px;
  color: var(--ink);
  display: inline-flex;
  font-size: 1.15rem;
  font-weight: 900;
  height: 42px;
  justify-content: center;
  min-width: 42px;
  padding: 0 12px;
}

.tabbar {
  background: rgba(248, 243, 234, 0.96);
  border-top: 1px solid var(--line);
  bottom: 0;
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(5, 1fr);
  left: 0;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  position: fixed;
  right: 0;
  z-index: 5;
}

.tab {
  background: transparent;
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  min-height: 44px;
}

.tab.active {
  background: var(--accent);
  color: white;
}

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

.field {
  display: grid;
  gap: 5px;
}

.field label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.compact-field {
  max-width: 220px;
}

.compact-field .input {
  min-height: 40px;
}

.check-field {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 0.9rem;
  font-weight: 800;
  gap: 9px;
  min-height: 38px;
}

.check-field input {
  accent-color: var(--accent);
  height: 20px;
  width: 20px;
}

.input,
.select,
.textarea {
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  min-height: 44px;
  padding: 10px;
  width: 100%;
}

.textarea {
  min-height: 78px;
  resize: vertical;
}

.details-panel {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  padding-top: 10px;
}

.details-panel summary {
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
}

.details-panel form {
  margin-top: 10px;
}

.hidden-input {
  display: none;
}

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

.workout-block {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.block-head {
  background: var(--panel-soft);
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 8px;
  padding: 12px;
}

.block-body {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.log-exercise {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  padding-top: 12px;
}

.log-exercise:first-child {
  border-top: 0;
  padding-top: 0;
}

.last-time {
  background: #f5efe5;
  border: 1px solid #e4d9ca;
  border-radius: 10px;
  color: #4b514d;
  font-size: 0.86rem;
  line-height: 1.35;
  padding: 9px 10px;
}

.set-row {
  align-items: end;
  display: grid;
  gap: 8px;
  grid-template-columns: 34px 1fr 1fr 42px;
}

.set-row.bodyweight {
  grid-template-columns: 34px 1fr 42px;
}

.set-number {
  color: var(--muted);
  font-weight: 900;
  padding-bottom: 11px;
  text-align: center;
}

.set-row .input {
  font-size: 1.05rem;
  font-weight: 800;
  text-align: center;
}

.done-btn {
  background: #e6ede7;
  border: 1px solid #cbd9cf;
  border-radius: 10px;
  color: #235044;
  font-weight: 900;
  height: 44px;
}

.done-btn.done {
  background: var(--accent);
  color: white;
}

.sticky-finish {
  background: rgba(248, 243, 234, 0.97);
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
  margin-top: 18px;
  padding: 10px 14px;
}

.sticky-finish .btn {
  margin: 0 auto;
  max-width: 820px;
  width: 100%;
}

.calendar {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.day-label {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 900;
  text-align: center;
}

.day {
  aspect-ratio: 1;
  background: #fffdf9;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  display: grid;
  font-size: 0.82rem;
  font-weight: 800;
  place-items: center;
  position: relative;
}

.day.has-session {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.day.has-session::after {
  background: rgba(255, 255, 255, 0.78);
  border-radius: 999px;
  bottom: 7px;
  content: "";
  height: 5px;
  position: absolute;
  width: 5px;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 10px;
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

.hidden {
  display: none !important;
}

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

  .workout-shell {
    padding-bottom: calc(112px + env(safe-area-inset-bottom));
  }

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

}
