:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --ink: #17201a;
  --muted: #67736a;
  --line: #ddd8cc;
  --green: #2f7d59;
  --green-dark: #19583c;
  --blue: #2c6b8f;
  --coral: #ca604d;
  --gold: #b57a23;
  --shadow: 0 16px 40px rgba(31, 38, 31, 0.1);
}

* {
  box-sizing: border-box;
}

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

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

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

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.8rem, 6vw, 3.6rem);
  line-height: 1.05;
}

h2 {
  margin-bottom: 0;
  font-size: 1.25rem;
}

.day-score {
  width: 86px;
  min-width: 86px;
  aspect-ratio: 1;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: white;
  box-shadow: var(--shadow);
}

.day-score span {
  font-size: 1.8rem;
  font-weight: 850;
  line-height: 1;
}

.day-score small {
  color: rgba(255, 255, 255, 0.78);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 10px 0 18px;
}

.metric-tile,
.panel,
.advisor-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-tile {
  min-height: 112px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.metric-tile span,
.goal-board span {
  color: var(--muted);
  font-size: 0.88rem;
}

.metric-tile strong,
.goal-board strong {
  display: block;
  font-size: 1.45rem;
  line-height: 1.15;
}

.metric-tile small {
  color: var(--muted);
}

.tabbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  padding: 8px 0 14px;
  background: var(--bg);
}

.tab-button,
.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.icon-button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 750;
}

.tab-button {
  background: var(--surface);
  color: var(--muted);
}

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

.panel {
  display: none;
  padding: 20px;
}

.panel.active {
  display: block;
}

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

.food-history-heading {
  margin-top: 18px;
}

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

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

.range-value {
  color: var(--green-dark);
  font-weight: 850;
}

.input-mode-note {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #edf2ed;
  color: var(--green-dark);
  padding: 12px 13px;
  font-size: 0.92rem;
  font-weight: 800;
}

.optional-upload input {
  background: #fff;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--ink);
  padding: 12px 13px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(47, 125, 89, 0.16);
}

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

.button-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 10px;
}

.intensity-guide,
.exercise-estimate {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 14px;
}

.intensity-guide {
  display: grid;
  gap: 5px;
}

.intensity-guide strong {
  color: var(--ink);
}

.intensity-guide span,
.exercise-estimate span,
.exercise-estimate small {
  color: var(--muted);
}

.exercise-estimate {
  display: grid;
  gap: 4px;
}

.exercise-estimate strong {
  font-size: 1.55rem;
}

.primary-button {
  background: var(--green);
  border-color: var(--green);
  color: white;
}

.secondary-button {
  background: #e9f0ea;
  color: var(--green-dark);
}

.ghost-button {
  background: #f5f8f4;
  border-color: #cdd9cf;
  color: var(--green-dark);
  padding-inline: 14px;
}

.danger-button {
  background: #a6402e;
  border-color: #a6402e;
  color: white;
  padding-inline: 14px;
  box-shadow: 0 10px 18px rgba(166, 64, 46, 0.16);
}

.hidden {
  display: none !important;
}

.icon-button {
  width: 44px;
  min-width: 44px;
  background: var(--surface-strong);
  color: var(--green-dark);
  font-size: 1.35rem;
  line-height: 1;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border-radius: 8px;
  background: #edf2ed;
  color: var(--green-dark);
  padding: 0 12px;
  font-size: 0.9rem;
  font-weight: 800;
  white-space: nowrap;
}

.photo-preview {
  min-height: 190px;
  border: 1px dashed #b8c2b9;
  border-radius: 8px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #f2f5f0;
  color: var(--muted);
  font-weight: 800;
}

.photo-preview img {
  width: 100%;
  height: 100%;
  max-height: 280px;
  object-fit: cover;
}

.food-response {
  border: 1px solid var(--line);
  border-left: 5px solid var(--green);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--muted);
  padding: 15px;
  line-height: 1.65;
  margin-top: 16px;
}

.food-response strong {
  color: var(--ink);
}

.sleep-tracker,
.sleep-quality-panel,
.sleep-message {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.sleep-tracker {
  display: grid;
  grid-template-columns: 1fr 156px;
  gap: 18px;
  align-items: center;
  padding: 16px;
  margin-bottom: 12px;
}

.sleep-tracker span,
.form-note {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
}

.sleep-tracker strong {
  display: block;
  margin-top: 5px;
  font-size: 1.35rem;
}

.sleep-tracker #sleepToggle {
  width: 156px;
  min-width: 156px;
  height: 156px;
  min-height: 156px;
  border-radius: 50%;
  padding: 18px;
  line-height: 1.2;
  box-shadow: 0 14px 28px rgba(47, 125, 89, 0.22);
}

.sleep-quality-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
  margin-bottom: 12px;
}

.sleep-quality-panel[hidden] {
  display: none;
}

.quality-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.sleep-message {
  margin-bottom: 16px;
  padding: 15px;
  border-left: 5px solid var(--blue);
  color: var(--muted);
  line-height: 1.65;
}

.sleep-message.is-good {
  border-left-color: var(--green);
  color: var(--green-dark);
}

.sleep-message.is-ok {
  border-left-color: var(--gold);
}

.sleep-message.is-bad {
  border-left-color: var(--coral);
}

.form-note {
  margin-bottom: 0;
}

.list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.calendar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.calendar-weekdays {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
  text-align: center;
}

.calendar-day {
  min-height: 118px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 10px;
  text-align: left;
  cursor: pointer;
}

.calendar-day.is-empty {
  background: transparent;
  border-color: transparent;
  cursor: default;
}

.calendar-day.is-today {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(47, 125, 89, 0.12);
}

.calendar-day.is-selected {
  background: #edf2ed;
  border-color: var(--green-dark);
}

.calendar-date {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 8px;
  font-weight: 850;
}

.calendar-score {
  min-width: 28px;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  padding: 3px 6px;
  font-size: 0.72rem;
  text-align: center;
}

.calendar-stats {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.25;
}

.calendar-stats b {
  color: var(--ink);
}

.day-detail {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 15px;
  color: var(--muted);
  line-height: 1.65;
}

.day-detail strong {
  color: var(--ink);
}

.entry-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 13px;
}

.entry-item header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

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

.text-button {
  min-height: 32px;
  border: 1px solid #cdd9cf;
  border-radius: 999px;
  background: #f5f8f4;
  color: var(--green-dark);
  padding: 0 12px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 800;
}

.text-button:hover,
.ghost-button:hover,
.secondary-button:hover {
  border-color: var(--green);
}

.danger-button:hover {
  background: #8f3324;
  border-color: #8f3324;
}

.entry-item strong {
  font-size: 1rem;
}

.entry-item p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.entry-item small {
  color: var(--muted);
}

.goal-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 18px;
}

.goal-board > div {
  min-height: 96px;
  border-radius: 8px;
  padding: 15px;
  color: white;
}

.goal-board > div:nth-child(1) {
  background: var(--blue);
}

.goal-board > div:nth-child(2) {
  background: var(--green-dark);
}

.goal-board > div:nth-child(3) {
  background: var(--coral);
}

.goal-board span {
  color: rgba(255, 255, 255, 0.8);
}

.advisor-card {
  padding: 18px;
  margin-bottom: 16px;
  border-left: 5px solid var(--gold);
}

.advisor-card p {
  margin-bottom: 0;
  line-height: 1.7;
}

@media (max-width: 720px) {
  .app-shell {
    padding: 14px;
  }

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

  .summary-grid,
  .goal-board {
    grid-template-columns: 1fr;
  }

  .tabbar {
    overflow-x: auto;
    grid-template-columns: repeat(6, minmax(72px, 1fr));
  }

  .calendar-weekdays,
  .calendar-grid {
    gap: 5px;
  }

  .calendar-day {
    min-height: 86px;
    padding: 7px;
  }

  .calendar-stats {
    font-size: 0.68rem;
  }

  .panel {
    padding: 16px;
  }

  .inline-fields,
  .sleep-tracker,
  .quality-buttons {
    grid-template-columns: 1fr;
  }

  .sleep-tracker {
    justify-items: center;
    text-align: center;
  }

  .sleep-tracker #sleepToggle {
    width: 148px;
    min-width: 148px;
    height: 148px;
    min-height: 148px;
  }

  .day-score {
    width: 74px;
    min-width: 74px;
  }
}
