:root {
  color-scheme: light;
  --bg: #f6f8f4;
  --surface: #ffffff;
  --surface-soft: #eef5ef;
  --ink: #1f2a24;
  --muted: #66736d;
  --line: #d9e2dc;
  --accent: #2f6b4f;
  --accent-strong: #24543e;
  --coral: #c95f4d;
  --blue: #3b6ea8;
  --shadow: 0 10px 30px rgba(31, 42, 36, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(238, 245, 239, 0.7), rgba(246, 248, 244, 0) 280px),
    var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(59, 110, 168, 0.35);
  outline-offset: 2px;
}

.shell {
  width: min(100%, 840px);
  margin: 0 auto;
  padding: 16px;
}

.login-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.login-panel {
  width: min(100%, 420px);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-panel h1,
.topbar h1,
.section-heading h2 {
  margin: 4px 0 0;
  line-height: 1.15;
}

.login-panel h1 {
  font-size: 30px;
}

.topbar h1 {
  font-size: 28px;
}

.section-heading h2 {
  font-size: 22px;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.login-form {
  display: grid;
  gap: 10px;
  margin-top: 28px;
}

.password-row {
  display: grid;
  grid-template-columns: 1fr 88px;
  gap: 10px;
}

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

.login-form button,
.weight-form button {
  color: #fff;
  background: var(--accent);
  font-weight: 700;
}

.form-error {
  min-height: 20px;
  margin: 4px 0 0;
  color: #a33b2f;
}

.app-view {
  display: grid;
  gap: 16px;
  padding-bottom: 32px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-top: 8px;
}

.ghost-button {
  min-width: 64px;
  color: var(--accent-strong);
  background: rgba(47, 107, 79, 0.1);
  font-weight: 700;
}

.day-tabs {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(74px, 1fr);
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 6px;
  scrollbar-width: thin;
}

.day-tab,
.weight-profile-button {
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  font-weight: 700;
  white-space: nowrap;
}

.day-tab.is-active,
.weight-profile-button.is-active {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

.day-tab small {
  display: block;
  margin-top: 1px;
  color: currentColor;
  font-size: 11px;
  font-weight: 600;
  opacity: 0.78;
}

.day-summary {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--blue));
  box-shadow: var(--shadow);
}

.summary-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.summary-title h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
}

.summary-title span {
  flex: 0 0 auto;
  font-size: 14px;
  opacity: 0.9;
}

.summary-compare {
  display: grid;
  gap: 10px;
}

.profile-summary {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
}

.profile-summary h3 {
  margin: 0;
  font-size: 16px;
}

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

.nutrition-item {
  min-width: 0;
  padding: 10px 8px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
}

.nutrition-item b {
  display: block;
  font-size: 18px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.nutrition-item span {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  opacity: 0.88;
}

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

.meal-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.meal-image-wrap {
  position: relative;
  aspect-ratio: 4 / 3;
  background: linear-gradient(135deg, #e9f2e9, #f7f3ed);
}

.meal-image-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-fallback {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  padding: 18px;
  color: var(--accent-strong);
  font-weight: 800;
  text-align: center;
}

.meal-image-wrap.is-missing .image-fallback {
  display: grid;
}

.meal-body {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.meal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.meal-header h3 {
  margin: 4px 0 0;
  font-size: 21px;
  line-height: 1.2;
}

.slot-pill {
  flex: 0 0 auto;
  padding: 6px 9px;
  border-radius: 8px;
  color: var(--coral);
  background: rgba(201, 95, 77, 0.12);
  font-size: 13px;
  font-weight: 800;
}

.meal-card .nutrition-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.meal-card .nutrition-item {
  border-color: #e4ebe6;
  color: var(--ink);
  background: #f9fbf9;
}

.meal-card .nutrition-item span {
  color: var(--muted);
  opacity: 1;
}

.person-panels {
  display: grid;
  gap: 12px;
}

.person-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid #dfe7e2;
  border-radius: 8px;
  background: #fbfcfb;
}

.person-panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.person-panel-header h4 {
  margin: 0;
  font-size: 17px;
}

.person-panel-header span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

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

.ingredient-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ingredient-list li {
  max-width: 100%;
  padding: 7px 9px;
  border: 1px solid #dfe7e2;
  border-radius: 8px;
  color: #31423a;
  background: #fbfcfb;
  overflow-wrap: anywhere;
}

.method {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.weight-panel {
  display: grid;
  gap: 14px;
  margin-top: 8px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.mini-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  min-width: 128px;
}

.weight-profile-button {
  min-height: 38px;
  font-size: 14px;
}

.weight-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.weight-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.weight-form .note-field,
.weight-form button {
  grid-column: 1 / -1;
}

.form-message {
  min-height: 20px;
  margin: 0;
  color: var(--accent-strong);
}

.weight-chart {
  min-height: 152px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.chart-empty {
  display: grid;
  min-height: 152px;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.weight-list {
  display: grid;
  gap: 8px;
}

.weight-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.weight-row:first-child {
  border-top: 0;
}

.weight-date {
  color: var(--muted);
  font-size: 13px;
}

.weight-value {
  font-size: 18px;
  font-weight: 800;
}

.delete-button {
  width: 44px;
  min-width: 44px;
  color: #a33b2f;
  background: rgba(163, 59, 47, 0.1);
  font-size: 22px;
  line-height: 1;
}

.footer-note {
  padding: 12px 4px 28px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

[hidden] {
  display: none !important;
}

@media (min-width: 560px) {
  .summary-compare,
  .person-panels {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .meal-card {
    display: grid;
    grid-template-columns: 260px 1fr;
  }

  .meal-image-wrap {
    aspect-ratio: auto;
    min-height: 100%;
  }

  .weight-form {
    grid-template-columns: 1fr 1fr 2fr auto;
    align-items: end;
  }

  .weight-form .note-field,
  .weight-form button {
    grid-column: auto;
  }

  .weight-form button {
    min-width: 88px;
  }
}

@media (max-width: 420px) {
  .shell {
    padding: 12px;
  }

  .topbar h1 {
    font-size: 24px;
  }

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

  .meal-header {
    display: grid;
  }

  .slot-pill {
    justify-self: start;
  }
}
