:root {
  color-scheme: light;
  --bg: #f8f5ee;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --ink: #2b302b;
  --muted: #73796f;
  --line: #e7e1d6;
  --green: #8faa82;
  --green-dark: #5f7c58;
  --green-soft: #edf3e8;
  --cream: #fff8e8;
  --gray: #f0efeb;
  --danger: #b8655d;
  --shadow: 0 14px 34px rgba(66, 62, 51, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100%;
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, #edf3e8 0, rgba(237, 243, 232, 0) 230px),
    var(--bg);
}

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

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 720px);
  min-height: 100vh;
  margin: 0 auto;
  position: relative;
}

.app-main {
  padding: max(18px, env(safe-area-inset-top)) 16px calc(96px + env(safe-area-inset-bottom));
}

.view {
  display: none;
  animation: fadeUp 220ms ease;
}

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

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.home-hero,
.page-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding: 18px 2px 12px;
}

.home-hero h1,
.page-header h1 {
  margin: 5px 0 7px;
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: 0;
}

.page-header {
  align-items: center;
}

.page-header .primary-button {
  flex: 0 0 auto;
}

.eyebrow {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
  color: var(--green-dark);
  font-weight: 700;
}

.hero-copy,
.section-heading p,
.soft-note {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.section-block {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.82);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

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

.section-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
}

.section-heading h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.35;
  letter-spacing: 0;
}

.mainline-grid,
.task-list,
.entry-list,
.settings-list,
.progress-stack {
  display: grid;
  gap: 10px;
}

.mainline-card,
.task-card,
.entry-card,
.settings-row,
.placeholder-grid article {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.mainline-card {
  padding: 13px;
}

.mainline-kicker,
.task-meta,
.entry-meta,
.mini-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.mainline-card strong {
  display: block;
  margin-top: 5px;
  font-size: 15px;
}

.mainline-card p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.status-pill,
.primary-button,
.text-button,
.wide-action,
.icon-button,
.task-action,
.quick-choice {
  min-height: 40px;
  border: 0;
  border-radius: var(--radius);
  font-weight: 700;
}

.status-pill {
  flex: 0 0 auto;
  padding: 0 12px;
  color: var(--green-dark);
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(143, 170, 130, 0.42);
}

.status-pill.is-low {
  color: #806234;
  background: #fff3d2;
  border-color: #efd596;
}

.primary-button,
.wide-action,
.task-action {
  color: #fff;
  background: var(--green-dark);
}

.primary-button {
  padding: 0 14px;
}

.text-button {
  padding: 0 4px;
  color: var(--green-dark);
  background: transparent;
}

.icon-button {
  width: 40px;
  flex: 0 0 40px;
  color: var(--green-dark);
  background: var(--green-soft);
  font-size: 22px;
  line-height: 1;
}

.icon-button.subtle {
  color: var(--muted);
  background: var(--gray);
}

.wide-action {
  width: 100%;
  font-size: 15px;
}

.task-card {
  padding: 13px;
}

.task-topline,
.task-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.task-title {
  margin: 0 0 5px;
  font-size: 15px;
  line-height: 1.35;
}

.task-title.is-done {
  color: var(--muted);
  text-decoration: line-through;
}

.task-badge {
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--green-dark);
  background: var(--green-soft);
  font-size: 12px;
  font-weight: 700;
}

.task-step {
  margin: 10px 0;
  padding: 10px;
  border-radius: var(--radius);
  color: #4e5b4c;
  background: #f4f7ef;
  font-size: 13px;
  line-height: 1.5;
}

.task-action {
  flex: 1;
}

.task-secondary,
.task-delete {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
}

.task-delete {
  width: 42px;
  color: var(--danger);
}

.timer-panel {
  display: none;
  margin-top: 10px;
  padding: 10px;
  border-radius: var(--radius);
  background: #fbf1dd;
  color: #6d5730;
  font-weight: 700;
  text-align: center;
}

.timer-panel.is-active {
  display: block;
}

.health-grid,
.placeholder-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.health-item,
.progress-item {
  padding: 12px;
  border-radius: var(--radius);
  background: var(--gray);
}

.health-item strong,
.placeholder-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 17px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.meal-photo-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.meal-thumb,
.meal-empty {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.meal-thumb {
  position: relative;
  display: block;
  overflow: hidden;
  padding: 0;
  aspect-ratio: 1;
}

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

.meal-thumb span {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 6px;
  padding: 3px 5px;
  border-radius: 6px;
  color: #fff;
  background: rgba(43, 48, 43, 0.62);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
}

.meal-empty {
  grid-column: 1 / -1;
  min-height: 42px;
  color: var(--green-dark);
  font-weight: 800;
}

.health-detail {
  display: grid;
  gap: 0;
}

.detail-summary .soft-note {
  margin-top: 12px;
}

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

.health-record-card {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.health-record-card h2 {
  margin: 0 0 5px;
  font-size: 15px;
  line-height: 1.35;
}

.health-record-card p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.progress-item {
  display: grid;
  gap: 8px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
}

.progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
}

.progress-track {
  height: 7px;
  border-radius: 99px;
  overflow: hidden;
  background: #ebe6dc;
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.task-board {
  display: grid;
  gap: 16px;
}

.board-column {
  display: grid;
  gap: 10px;
}

.board-column h2 {
  margin: 0;
  font-size: 15px;
}

.entry-card {
  padding: 13px;
}

.entry-card h2 {
  margin: 0 0 7px;
  font-size: 15px;
}

.entry-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.entry-image {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  margin-top: 10px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.placeholder-grid {
  margin-top: 14px;
}

.placeholder-grid article {
  padding: 14px;
}

.placeholder-grid span {
  color: var(--muted);
  font-size: 12px;
}

.soft-note {
  margin-top: 14px;
}

.settings-row {
  width: 100%;
  padding: 14px;
  text-align: left;
  background: var(--surface-strong);
}

.settings-row span,
.settings-row small {
  display: block;
}

.settings-row span {
  font-weight: 800;
}

.settings-row small {
  margin-top: 4px;
  color: var(--muted);
}

.settings-row.danger span {
  color: var(--danger);
}

.cloud-status {
  cursor: default;
}

.cloud-status span::after {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-left: 8px;
  border-radius: 50%;
  background: #d2c6b0;
}

.cloud-status.is-online span::after {
  background: var(--green);
}

.cloud-status.is-error span::after {
  background: var(--danger);
}

.file-row {
  position: relative;
  cursor: pointer;
}

.file-row input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  width: min(100%, 720px);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(223, 216, 204, 0.92);
  background: rgba(255, 253, 248, 0.94);
  backdrop-filter: blur(20px);
  transform: translateX(-50%);
}

.nav-item {
  min-width: 0;
  min-height: 54px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.nav-item span {
  display: block;
}

.nav-icon {
  margin-bottom: 3px;
  font-size: 18px;
  line-height: 1;
}

.nav-item.is-active {
  color: var(--green-dark);
  background: var(--green-soft);
}

.floating-add {
  position: fixed;
  right: max(16px, calc((100vw - 720px) / 2 + 16px));
  bottom: calc(82px + env(safe-area-inset-bottom));
  z-index: 19;
  width: 54px;
  height: 54px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: #4f684b;
  box-shadow: 0 14px 30px rgba(79, 104, 75, 0.28);
  font-size: 28px;
  line-height: 1;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  align-items: end;
  padding: 18px 12px calc(18px + env(safe-area-inset-bottom));
  background: rgba(43, 48, 43, 0.28);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(100%, 680px);
  max-height: min(86vh, 760px);
  margin: 0 auto;
  overflow: auto;
  padding: 16px;
  border-radius: 14px 14px var(--radius) var(--radius);
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(43, 48, 43, 0.18);
}

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

.modal-header h2 {
  margin: 0;
  font-size: 18px;
}

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

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

.form-grid input,
.form-grid select,
.form-grid textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

.form-grid textarea {
  resize: vertical;
}

.full-width {
  grid-column: 1 / -1;
}

.meal-upload-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--green-soft);
}

.meal-upload-heading {
  grid-column: 1 / -1;
}

.meal-upload-heading strong,
.meal-upload-heading span {
  display: block;
}

.meal-upload-heading strong {
  color: var(--ink);
}

.meal-upload-heading span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.meal-upload-group label {
  min-width: 0;
}

.meal-preview {
  min-height: 44px;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 12px;
}

.meal-preview-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  aspect-ratio: 4 / 3;
}

.meal-preview-card img,
.image-viewer img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.meal-preview-card .task-delete {
  position: absolute;
  top: 7px;
  right: 7px;
  min-height: 34px;
  width: 34px;
  background: rgba(255, 253, 248, 0.9);
}

.image-viewer {
  display: grid;
  gap: 12px;
}

.image-viewer img {
  max-height: 62vh;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.quick-menu {
  display: grid;
  gap: 10px;
}

.quick-choice {
  width: 100%;
  color: var(--ink);
  background: var(--green-soft);
}

.empty-state {
  padding: 20px 14px;
  border: 1px dashed #d9d1c3;
  border-radius: var(--radius);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.52);
  text-align: center;
  font-size: 14px;
  line-height: 1.6;
}

@media (min-width: 760px) {
  .app-main {
    padding-inline: 24px;
  }

  .mainline-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .health-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .task-board {
    grid-template-columns: repeat(3, 1fr);
    align-items: start;
  }
}

@media (max-width: 380px) {
  .home-hero {
    flex-direction: column;
  }

  .health-grid,
  .placeholder-grid {
    grid-template-columns: 1fr;
  }

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

  .meal-upload-group,
  .meal-photo-strip {
    grid-template-columns: 1fr 1fr;
  }
}
