:root {
  color-scheme: light;
  --bg: #f5f7f2;
  --panel: #ffffff;
  --panel-soft: #f9faf6;
  --line: #dbe3d7;
  --line-strong: #c6d2bf;
  --text: #1f2b1d;
  --muted: #60705a;
  --green: #2f472b;
  --green-soft: #eaf0e5;
  --amber-soft: #f2eadf;
  --blue-soft: #e5eef2;
  --danger: #9a332c;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

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

button {
  cursor: pointer;
}

#app {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

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

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 32px;
  line-height: 1;
}

h2 {
  font-size: 16px;
}

.tabs,
.range-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tab,
.secondary {
  border: 1px solid transparent;
  border-radius: 999px;
  background: #e7ece2;
  color: #51634b;
  min-height: 36px;
  padding: 0 13px;
  font-weight: 800;
}

.tab.active,
.range-button.active {
  background: var(--green);
  color: white;
}

.view {
  display: none;
}

.active-view {
  display: block;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  min-width: 0;
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.metric-card strong {
  display: block;
  margin: 5px 0;
  font-size: 30px;
  line-height: 1;
}

.metric-card em {
  display: block;
  min-height: 16px;
  color: #7a6b45;
  font-size: 12px;
  font-style: normal;
}

.today-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) 300px;
  gap: 14px;
}

.stack {
  display: grid;
  gap: 14px;
  align-content: start;
}

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

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

.muted,
.status {
  color: var(--muted);
  font-size: 12px;
}

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

label,
.field-block {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
  color: var(--text);
  min-height: 40px;
  padding: 9px 10px;
}

textarea {
  resize: vertical;
}

.label-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}

.chip-list,
.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.editable {
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  border-radius: 999px;
  background: var(--green-soft);
  color: #30482b;
  min-height: 32px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 800;
}

.food-chip {
  background: var(--amber-soft);
  color: #5b3c1c;
}

.calorie-chip {
  background: var(--blue-soft);
  color: #264d5a;
}

.chip button {
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, .08);
  width: 20px;
  height: 20px;
  padding: 0;
}

.food-entry,
.exercise-entry {
  display: grid;
  grid-template-columns: 1.2fr .8fr .7fr auto;
  gap: 8px;
}

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

.primary {
  border: 0;
  border-radius: 7px;
  background: var(--green);
  color: white;
  min-height: 44px;
  padding: 0 16px;
  font-weight: 900;
}

.danger {
  color: var(--danger);
}

.chart {
  display: flex;
  align-items: end;
  gap: 5px;
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: repeating-linear-gradient(0deg, #f7f9f5 0 22px, #eef3ea 23px 24px);
  padding: 10px;
}

.chart.large {
  min-height: 190px;
}

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

.line-chart-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 12px;
}

.line-chart-header,
.line-chart-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.line-chart-header {
  margin-bottom: 8px;
}

.line-chart-header h3 {
  margin: 0 0 2px;
  font-size: 14px;
  letter-spacing: 0;
}

.line-chart-header span,
.line-chart-footer {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.line-chart-header strong {
  font-size: 20px;
  white-space: nowrap;
}

.line-chart {
  display: block;
  width: 100%;
  height: 190px;
  overflow: visible;
}

.line-chart .grid-line {
  stroke: #dfe6da;
  stroke-width: 1;
}

.line-chart .line {
  fill: none;
  stroke: #607f55;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.line-chart .weight-line {
  stroke: #607f55;
}

.line-chart .rating-line {
  stroke: #8a6d3b;
}

.line-chart .miles-line {
  stroke: #4f8191;
}

.line-chart .calories-line {
  stroke: #8f6b51;
}

.line-chart circle {
  fill: white;
  stroke: currentColor;
  stroke-width: 2;
  color: #607f55;
}

.chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 190px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 14px;
}

.bar {
  flex: 1;
  min-width: 8px;
  border-radius: 6px 6px 0 0;
  background: #7f9f73;
}

.bar.secondary-bar {
  background: #6f99a7;
}

.recent-list,
.leaderboard {
  display: grid;
  gap: 8px;
}

.recent-item,
.leaderboard-item {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
  padding: 10px;
  text-align: left;
}

.recent-item {
  cursor: pointer;
}

.recent-title {
  font-weight: 900;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-meta {
  color: var(--muted);
  font-size: 12px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.settings-panel {
  max-width: 520px;
}

@media (max-width: 820px) {
  #app {
    width: min(100vw - 24px, 640px);
    padding-top: 14px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .tabs {
    width: 100%;
  }

  .tab {
    flex: 1;
  }

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

  .metric-grid {
    gap: 8px;
  }

  .metric-card:not(:first-child) {
    display: none;
  }

  .today-grid > aside {
    order: 2;
  }

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

  .food-entry input:first-child,
  .exercise-entry input:first-child,
  .food-entry button,
  .exercise-entry button {
    grid-column: 1 / -1;
  }
}
