:root {
  color-scheme: light;
  --ink: #17201c;
  --muted: #61706a;
  --panel: #ffffff;
  --line: #d9e2de;
  --wash: #f3f7f5;
  --deep: #18372c;
  --green: #2f7d57;
  --teal: #277f89;
  --gold: #b66b22;
  --red: #b94a48;
  --blue: #2f6fbd;
  --shadow: 0 16px 35px rgba(24, 55, 44, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #eef5f1 0%, #f7f8f4 42%, #edf4f7 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

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

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 0 0 36px;
}

.topbar {
  position: relative;
  min-height: 248px;
  overflow: hidden;
  background: var(--deep);
}

.topbar__image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.topbar__shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(13, 29, 23, 0.86), rgba(13, 29, 23, 0.36) 58%, rgba(13, 29, 23, 0.15)),
    linear-gradient(180deg, rgba(13, 29, 23, 0.16), rgba(13, 29, 23, 0.72));
}

.topbar__content {
  position: relative;
  z-index: 1;
  min-height: 248px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding: 96px 22px 24px;
  color: #fff;
}

.topbar__content > div:first-child {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.86;
}

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

h1 {
  margin-bottom: 0;
  max-width: 620px;
  font-size: 3.4rem;
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 14px;
  font-size: 1.35rem;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 10px;
  font-size: 1rem;
  letter-spacing: 0;
}

.today-pill {
  min-width: 96px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(10px);
  font-weight: 800;
  white-space: nowrap;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  min-height: 58px;
  width: 100%;
  padding: 8px;
  background: rgba(246, 250, 248, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.tab {
  min-width: 0;
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.view {
  display: none;
  padding: 18px;
}

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

.band {
  margin-bottom: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.band--flush {
  padding: 0;
  overflow: hidden;
}

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

.summary-tile {
  min-height: 92px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.summary-tile strong {
  display: block;
  margin-top: 6px;
  font-size: 1.35rem;
  line-height: 1.1;
}

.summary-tile span,
.field span,
.small-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.today-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 14px;
}

.workout-focus {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.focus-title {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.focus-title p {
  margin-bottom: 0;
  color: var(--muted);
}

.status-badge {
  min-width: 84px;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #e2f2e7;
  color: #195d38;
  font-weight: 900;
  white-space: nowrap;
}

.status-badge.warn {
  background: #fff0d8;
  color: #8a4b14;
}

.status-badge.danger {
  background: #ffe0df;
  color: #8d2d2c;
}

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

.checklist li {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  color: #26332e;
}

.check-dot {
  width: 20px;
  height: 20px;
  border: 2px solid var(--green);
  border-radius: 50%;
  margin-top: 1px;
}

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

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

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

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid #c9d6d0;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(39, 127, 137, 0.16);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.button {
  min-height: 42px;
  border: 1px solid var(--deep);
  border-radius: 6px;
  background: var(--deep);
  color: #fff;
  padding: 0 14px;
  font-weight: 900;
}

.button.secondary {
  background: #fff;
  color: var(--deep);
}

.button.ghost {
  border-color: var(--line);
  background: #f8fbfa;
  color: var(--muted);
}

.icon-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  padding: 0 10px;
  font-size: 0.8rem;
  font-weight: 900;
}

.range {
  accent-color: var(--green);
}

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

.day-card {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) 116px;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.day-card:last-child {
  border-bottom: 0;
}

.day-card.is-today {
  background: #eff8f2;
}

.day-date {
  color: var(--muted);
  font-weight: 900;
}

.day-main strong {
  display: block;
  margin-bottom: 4px;
}

.day-main span {
  color: var(--muted);
  font-size: 0.92rem;
}

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

.plan-card,
.meal-card {
  min-height: 172px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.plan-card h3,
.meal-card h3 {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.plan-card p,
.meal-card p {
  margin-bottom: 8px;
  color: #33443d;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #edf5f2;
  color: var(--teal);
  font-size: 0.76rem;
  font-weight: 900;
  white-space: nowrap;
}

.meal-filter {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.meal-log-head {
  display: grid;
  grid-template-columns: minmax(180px, 0.7fr) minmax(0, 1.3fr);
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.meal-total-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.meal-total-row strong {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfdfc;
  font-size: 0.9rem;
  text-align: center;
}

.meal-entry-form {
  display: grid;
  grid-template-columns: 130px minmax(160px, 1fr) repeat(4, minmax(74px, 0.55fr)) 104px;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

.meal-entry-form .button {
  width: 100%;
}

.meal-entry-list {
  display: grid;
  gap: 9px;
}

.meal-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.meal-entry strong {
  display: block;
  margin: 7px 0 3px;
}

.meal-entry small {
  color: var(--muted);
  font-weight: 700;
}

.filter-chip {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  padding: 0 12px;
  font-weight: 900;
  white-space: nowrap;
}

.filter-chip.is-active {
  border-color: var(--green);
  background: #eaf6ef;
  color: #1d6840;
}

.chart-wrap {
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.chart {
  display: block;
  width: 100%;
  height: 220px;
}

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

.notice {
  margin: 12px 0 0;
  padding: 12px;
  border-left: 4px solid var(--gold);
  background: #fff7ea;
  color: #70400f;
  border-radius: 6px;
}

.quiet-note {
  margin: 0 0 12px;
  color: var(--muted);
}

.score-card {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(260px, 1.05fr);
  gap: 16px;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.score-card h2 {
  margin: 4px 0 6px;
  font-size: 2rem;
}

.score-card p {
  margin-bottom: 0;
  color: #33443d;
  overflow-wrap: anywhere;
}

.score-card--green {
  background: #eaf7ef;
  border-color: #badfc8;
}

.score-card--yellow {
  background: #fff6df;
  border-color: #ecd39e;
}

.score-card--red {
  background: #fff0ef;
  border-color: #efc0be;
}

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

.score-checks span {
  min-height: 54px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  padding: 9px 10px;
  border: 1px solid rgba(97, 112, 106, 0.24);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.64);
  color: var(--muted);
  font-weight: 900;
}

.score-checks span.is-done {
  color: #1f6b42;
}

.score-checks small {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
}

.details-drawer {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.details-drawer summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  color: var(--deep);
  font-weight: 900;
  cursor: pointer;
}

.details-grid {
  padding: 0 0 14px;
}

.mfp-box {
  margin: 14px 0;
  padding: 13px;
  border: 1px solid #c8d9dc;
  border-radius: 8px;
  background: #eef8fa;
}

.mfp-box p {
  margin: 6px 0 10px;
  color: #35535a;
}

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

.macro-row strong {
  min-height: 38px;
  display: flex;
  align-items: center;
  padding: 8px 9px;
  border-radius: 6px;
  background: #fff;
}

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

.week-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.week-card h3 {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.week-card p {
  margin-bottom: 6px;
}

.hidden-file {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 760px) {
  .topbar,
  .topbar__content {
    min-height: 218px;
  }

  .topbar__content {
    align-items: end;
    padding: 72px 16px 18px;
  }

  h1 {
    font-size: 2.1rem;
  }

  .today-pill {
    align-self: end;
    min-width: 76px;
    font-size: 0.86rem;
  }

  .tabs {
    display: flex;
    overflow-x: auto;
    min-height: 62px;
    padding: 7px 5px;
  }

  .tab {
    flex: 0 0 74px;
    min-height: 46px;
    padding: 0 4px;
    font-size: 0.68rem;
  }

  .view {
    padding: 14px 10px;
  }

  .band {
    padding: 14px;
  }

  .today-layout,
  .progress-grid,
  .plan-grid,
  .meal-grid,
  .summary-grid,
  .score-card,
  .week-grid,
  .meal-log-head {
    grid-template-columns: 1fr;
  }

  .score-checks {
    grid-template-columns: 1fr;
  }

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

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

  .field--meal-name,
  .meal-entry-form .button {
    grid-column: 1 / -1;
  }

  .metric-grid,
  .form-grid {
    grid-template-columns: 1fr 1fr;
  }

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

  .day-card {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

@media (max-width: 420px) {
  .topbar__content {
    flex-direction: column;
    align-items: start;
    justify-content: end;
  }

  .today-pill {
    align-self: start;
  }

  .metric-grid,
  .form-grid,
  .meal-total-row,
  .meal-entry-form {
    grid-template-columns: 1fr;
  }

  .meal-entry {
    grid-template-columns: 1fr;
  }
}
