/* =========================================================
   卡路里计算器 — 静态单页应用样式
   配色：柔和绿 + 米白，数据用低饱和色区分
   ========================================================= */

:root {
  --bg: #f4f7f2;
  --surface: #ffffff;
  --surface-2: #edf3ec;
  --surface-3: #f7faf6;
  --ink: #1d2a23;
  --ink-soft: #34463b;
  --muted: #6f7f74;
  --muted-2: #8a978e;
  --line: #e1e9df;
  --line-strong: #d2ddcf;
  --primary: #2f7d5b;
  --primary-strong: #246347;
  --primary-soft: #e4f1e9;
  --primary-wash: #f1f8f3;
  --amber: #c9862b;
  --amber-soft: #fbf1df;
  --danger: #b24b42;
  --danger-soft: #fbecea;
  --protein: #506fd0;
  --protein-soft: #e8edfb;
  --carbs: #c98a2c;
  --carbs-soft: #fbf0dc;
  --fat: #a95f96;
  --fat-soft: #f6eaf2;
  --radius-lg: 20px;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 1px 2px rgba(25, 47, 34, 0.04), 0 14px 38px rgba(25, 47, 34, 0.06);
  --shadow-soft: 0 1px 2px rgba(25, 47, 34, 0.04), 0 6px 18px rgba(25, 47, 34, 0.05);
  --glass-bg: linear-gradient(145deg, rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0.58));
  --glass-border: rgba(255, 255, 255, 0.72);
  --glass-shadow: 0 1px 2px rgba(25, 47, 34, 0.04), 0 18px 46px rgba(35, 74, 52, 0.09);
  --shadow-hover: 0 2px 4px rgba(25, 47, 34, 0.04), 0 22px 52px rgba(35, 74, 52, 0.13);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  background:
    radial-gradient(1200px 500px at 12% -8%, rgba(219, 236, 220, 0.75), transparent 62%),
    radial-gradient(900px 420px at 96% 4%, rgba(248, 236, 210, 0.5), transparent 58%),
    var(--bg);
}

body.modal-open {
  overflow: hidden;
}

.ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(44% 38% at 14% 10%, rgba(126, 190, 155, 0.34), transparent 70%),
    radial-gradient(38% 34% at 88% 6%, rgba(244, 214, 160, 0.3), transparent 72%),
    radial-gradient(42% 38% at 72% 88%, rgba(167, 208, 187, 0.2), transparent 70%);
  animation: ambient-drift 26s ease-in-out infinite alternate;
}

@keyframes ambient-drift {
  from {
    transform: translate3d(-1.4%, -0.8%, 0) scale(1.02);
  }
  to {
    transform: translate3d(1.4%, 1%, 0) scale(1.07);
  }
}

.app {
  position: relative;
  z-index: 1;
}

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

button {
  cursor: pointer;
}

a {
  color: var(--primary-strong);
  text-underline-offset: 2px;
}

a:hover {
  color: var(--primary);
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 3px solid rgba(47, 125, 91, 0.34);
  outline-offset: 2px;
  border-radius: 6px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------------- 启动与骨架 ---------------- */

.app {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 22px 26px 56px;
}

.boot-screen {
  min-height: 72vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--muted);
}

.boot-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 17px;
  background: var(--primary);
  color: #fff;
  font-size: 24px;
  font-weight: 700;
  box-shadow: 0 12px 26px rgba(47, 125, 91, 0.24);
}

.noscript {
  margin: 24px auto;
  max-width: 640px;
  padding: 16px 18px;
  border: 1px solid #edc9c5;
  border-radius: var(--radius);
  background: var(--danger-soft);
  color: var(--danger);
}

/* ---------------- 顶部导航 ---------------- */

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

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.brand-mark {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 15px;
  background: linear-gradient(150deg, #3a916b, #246347);
  color: #fff;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 8px 20px rgba(36, 99, 71, 0.22);
}

.brand h1 {
  font-size: 19px;
  line-height: 1.25;
  letter-spacing: 0.01em;
}

.brand-sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12.5px;
}

.main-nav {
  display: flex;
  gap: 3px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 2px 8px rgba(25, 47, 34, 0.03);
  backdrop-filter: blur(10px);
}

.nav-btn {
  border: 0;
  border-radius: 999px;
  padding: 8px 17px;
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.nav-btn:hover {
  color: var(--ink);
  background: var(--surface-3);
}

.nav-btn.active {
  color: var(--primary-strong);
  background: var(--surface);
  box-shadow: 0 3px 9px rgba(25, 47, 34, 0.08);
}

/* ---------------- 页面与面板 ---------------- */

.view {
  animation: view-in 0.28s ease both;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.view-title {
  font-size: 24px;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.view-sub {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13.5px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 22px 0;
}

.panel-title {
  font-size: 16px;
  line-height: 1.3;
}

.panel-sub {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12.5px;
}

.panel-body {
  padding: 18px 22px 22px;
}

.section-gap {
  margin-top: 18px;
}

/* ---------------- 通用按钮 ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 8px 15px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: var(--surface-2);
  color: var(--ink-soft);
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.14s ease, background 0.16s ease, border-color 0.16s ease,
    box-shadow 0.16s ease, color 0.16s ease;
}

.btn:hover {
  background: #e5ede4;
}

.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 7px 16px rgba(47, 125, 91, 0.18);
}

.btn.primary:hover {
  background: var(--primary-strong);
}

.btn.ghost {
  border-color: var(--line);
  background: var(--surface);
}

.btn.ghost:hover {
  border-color: var(--line-strong);
  background: var(--surface-3);
}

.btn.subtle {
  background: transparent;
  color: var(--muted);
}

.btn.subtle:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.btn.danger {
  border-color: #efd0cc;
  background: var(--danger-soft);
  color: var(--danger);
}

.btn.danger:hover {
  background: #f7ddd9;
}

.btn.sm {
  min-height: 32px;
  padding: 5px 11px;
  border-radius: 9px;
  font-size: 12.5px;
}

.btn.block {
  width: 100%;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.icon-btn {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.icon-btn:hover {
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--ink);
}

.icon-btn.danger:hover {
  border-color: #efd0cc;
  background: var(--danger-soft);
  color: var(--danger);
}

/* ---------------- 日期工具条 ---------------- */

.date-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 2px 8px rgba(25, 47, 34, 0.03);
}

.date-bar .icon-btn {
  width: 31px;
  height: 31px;
  border-radius: 8px;
  font-size: 20px;
}

.date-input {
  min-height: 31px;
  padding: 4px 7px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}

.date-input:hover {
  background: var(--surface-3);
}

.date-today {
  border: 0;
  border-left: 1px solid var(--line);
  padding: 4px 10px 4px 12px;
  background: transparent;
  color: var(--primary-strong);
  font-size: 12.5px;
  font-weight: 600;
}

.date-today:hover {
  color: var(--primary);
}

.date-today:disabled {
  color: var(--muted-2);
  cursor: default;
}

/* ---------------- 今日概览 ---------------- */

.summary-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(0, 0.98fr);
  gap: 18px;
  margin-bottom: 18px;
}

.intake-panel {
  overflow: hidden;
  position: relative;
}

.intake-panel::after {
  content: "";
  position: absolute;
  right: -60px;
  bottom: -90px;
  width: 230px;
  height: 230px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(47, 125, 91, 0.09), transparent 68%);
  pointer-events: none;
}

.intake-body {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 20px 24px 23px;
}

.ring-wrap {
  position: relative;
  width: 176px;
  height: 176px;
  flex: 0 0 auto;
}

.ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  overflow: visible;
}

.ring-track {
  fill: none;
  stroke: #eaf0e8;
  stroke-width: 10;
}

.ring-value {
  fill: none;
  stroke: var(--primary);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.55s cubic-bezier(0.2, 0.8, 0.2, 1), stroke 0.25s ease;
}

.ring-value.over {
  stroke: var(--amber);
}

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  text-align: center;
}

.ring-kcal {
  font-size: 31px;
  font-weight: 750;
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.ring-unit {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
}

.ring-caption {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.intake-copy {
  min-width: 0;
}

.eyebrow {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.intake-title {
  margin-top: 3px;
  font-size: 19px;
  line-height: 1.3;
}

.remaining-line {
  margin-top: 9px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
}

.remaining-value {
  font-size: 26px;
  font-weight: 750;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--primary-strong);
  font-variant-numeric: tabular-nums;
}

.remaining-value.over {
  color: var(--amber);
}

.remaining-label {
  color: var(--muted);
  font-size: 12.5px;
}

.intake-note {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12.5px;
  max-width: 34ch;
}

.mini-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 13px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-soft);
  font-size: 11.5px;
  font-weight: 600;
}

.chip.green {
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.chip.amber {
  background: var(--amber-soft);
  color: #8c5c14;
}

.chip.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.plan-panel {
  padding: 20px 22px 22px;
}

.plan-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  margin-top: 14px;
}

.metric {
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-3);
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.metric-value {
  display: block;
  margin-top: 2px;
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}

.metric-value small {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 500;
}

.plan-note {
  margin: 12px 0 0;
  padding: 9px 11px;
  border: 1px solid #f0e2bc;
  border-radius: 10px;
  background: #fff9e9;
  color: #7a5d24;
  font-size: 12px;
  line-height: 1.55;
}

.plan-note.muted {
  border-color: var(--line);
  background: var(--surface-3);
  color: var(--muted);
}

.macro-list {
  display: grid;
  gap: 11px;
  margin-top: 17px;
}

.macro-row {
  display: grid;
  gap: 5px;
}

.macro-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 11.5px;
}

.macro-label strong {
  color: var(--ink-soft);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.macro-bar {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1ea;
}

.macro-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  transition: width 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.macro-fill.protein {
  background: var(--protein);
}

.macro-fill.carbs {
  background: var(--carbs);
}

.macro-fill.fat {
  background: var(--fat);
}

.plan-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 16px;
  padding-top: 13px;
  border-top: 1px dashed var(--line);
  color: var(--muted);
  font-size: 11.5px;
}

.plan-foot a,
.plan-foot button {
  font-size: 12px;
}

/* ---------------- 今日主区域 ---------------- */

.today-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 326px;
  gap: 18px;
  align-items: start;
}

.log-panel {
  overflow: hidden;
}

.log-list {
  padding: 13px 18px 20px;
  display: grid;
  gap: 11px;
}

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

.meal-card.empty {
  background: var(--surface-3);
}

.meal-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 13px;
}

.meal-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.meal-card:nth-child(2) .meal-dot {
  background: #6c8f4f;
  box-shadow: 0 0 0 4px #eef4e7;
}

.meal-card:nth-child(3) .meal-dot {
  background: var(--amber);
  box-shadow: 0 0 0 4px var(--amber-soft);
}

.meal-card:nth-child(4) .meal-dot {
  background: var(--fat);
  box-shadow: 0 0 0 4px var(--fat-soft);
}

.meal-title {
  font-size: 14px;
  font-weight: 700;
}

.meal-kcal {
  margin-left: auto;
  color: var(--muted);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.meal-add {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 16px;
}

.entry-list {
  display: grid;
}

.entry {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 13px;
  border-top: 1px solid var(--line);
}

.entry:hover {
  background: #fbfdf9;
}

.entry-main {
  min-width: 0;
  flex: 1;
}

.entry-name {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.35;
}

.entry-name span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-meta {
  margin-top: 1px;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.entry-macros {
  display: none;
  color: var(--muted);
  font-size: 10.5px;
  white-space: nowrap;
}

.entry-actions {
  display: flex;
  align-items: center;
  gap: 1px;
  opacity: 0.65;
  transition: opacity 0.15s ease;
}

.entry:hover .entry-actions,
.entry:focus-within .entry-actions {
  opacity: 1;
}

.entry-actions .icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  font-size: 14px;
}

.entry-kcal {
  flex: 0 0 auto;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.empty-meal {
  padding: 0 13px 11px 34px;
  color: var(--muted-2);
  font-size: 11.5px;
}

.empty-meal button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--primary);
  font-size: 11.5px;
  font-weight: 600;
}

.empty-meal button:hover {
  text-decoration: underline;
}

/* ---------------- 右侧栏 ---------------- */

.side-col {
  display: grid;
  gap: 14px;
}

.side-card {
  padding: 17px 18px;
}

.side-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.profile-row {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-top: 12px;
}

.avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-size: 16px;
  font-weight: 750;
}

.profile-name {
  font-size: 15px;
  font-weight: 700;
}

.profile-meta {
  margin-top: 1px;
  color: var(--muted);
  font-size: 11.5px;
}

.profile-lines {
  display: grid;
  gap: 6px;
  margin-top: 13px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

.profile-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 11.5px;
}

.profile-line strong {
  color: var(--ink-soft);
  font-weight: 600;
}

.weight-value {
  margin-top: 12px;
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.weight-value strong {
  font-size: 29px;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.weight-value span {
  color: var(--muted);
  font-size: 12.5px;
}

.weight-delta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11.5px;
}

.weight-delta.good {
  color: var(--primary-strong);
}

.weight-delta.up {
  color: var(--amber);
}

.mini-weight-list {
  display: grid;
  gap: 4px;
  margin-top: 11px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}

.mini-weight-row {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
}

.mini-weight-row strong {
  color: var(--ink-soft);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.api-line {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.quota-bar {
  height: 5px;
  overflow: hidden;
  margin-top: 8px;
  border-radius: 999px;
  background: var(--surface-2);
}

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

.quota-fill.high {
  background: var(--amber);
}

/* ---------------- 引导 / 提示卡 ---------------- */

.onboarding {
  margin-bottom: 18px;
  border-color: #cfe3d5;
  background:
    linear-gradient(135deg, rgba(232, 245, 235, 0.9), rgba(255, 255, 255, 0.96) 62%),
    var(--surface);
}

.onboarding-body {
  padding: 21px 24px 22px;
}

.onboarding h2 {
  margin-top: 3px;
  font-size: 21px;
  line-height: 1.3;
}

.onboarding p {
  margin-top: 6px;
  max-width: 66ch;
  color: var(--muted);
  font-size: 13px;
}

.onboarding-form {
  margin-top: 17px;
}

.banner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
  padding: 11px 14px;
  border: 1px solid #eedcbc;
  border-radius: 12px;
  background: var(--amber-soft);
  color: #76511b;
  font-size: 12.5px;
}

.banner.danger {
  border-color: #efd0cc;
  background: var(--danger-soft);
  color: var(--danger);
}

.banner .btn {
  margin-left: auto;
}

.weight-prompt {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
  padding: 15px 18px;
  border: 1px solid #cfe3d5;
  border-radius: var(--radius);
  background: var(--primary-wash);
}

.weight-prompt-text {
  flex: 1 1 260px;
  font-size: 13px;
}

.weight-prompt-text strong {
  display: block;
  font-size: 14px;
}

.weight-prompt-text span {
  color: var(--muted);
  font-size: 12px;
}

.weight-prompt form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.weight-prompt .field {
  min-width: 112px;
}

/* ---------------- 表单 ---------------- */

.field {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.field > label,
.field-label {
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
}

.field .hint {
  color: var(--muted-2);
  font-size: 10.5px;
  line-height: 1.4;
}

.input,
.select {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13.5px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.input:hover,
.select:hover {
  border-color: #bccdb9;
}

.input:focus,
.select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 125, 91, 0.12);
}

.input::placeholder {
  color: #a4b0a8;
}

.input[type="number"] {
  font-variant-numeric: tabular-nums;
}

.select {
  appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%236f7f74' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
}

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

.form-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-grid .span-2 {
  grid-column: span 2;
}

.form-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.form-error {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12px;
}

.form-success {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-size: 12px;
}

.hint {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.55;
}

.radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.radio-pill {
  position: relative;
}

.radio-pill input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.radio-pill span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s ease;
}

.radio-pill input:focus-visible + span {
  outline: 3px solid rgba(47, 125, 91, 0.3);
  outline-offset: 2px;
}

.radio-pill input:checked + span {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.radio-pill input:disabled + span {
  cursor: not-allowed;
  opacity: 0.55;
}

/* ---------------- 趋势 ---------------- */

.segmented {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.segment {
  min-height: 30px;
  padding: 4px 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.segment:hover {
  color: var(--ink);
  background: var(--surface-3);
}

.segment.active {
  background: var(--primary-soft);
  color: var(--primary-strong);
}

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

.stat-card {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.stat-card-label {
  color: var(--muted);
  font-size: 11.5px;
}

.stat-card-value {
  margin-top: 3px;
  font-size: 25px;
  font-weight: 750;
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat-card-value small {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
}

.stat-card-sub {
  margin-top: 2px;
  color: var(--muted-2);
  font-size: 11px;
}

.chart-panel {
  margin-bottom: 17px;
  overflow: hidden;
}

.chart-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px 8px;
}

.chart-title {
  font-size: 15px;
}

.chart-sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11.5px;
}

.chart-body {
  padding: 4px 10px 14px;
  overflow-x: auto;
}

.chart-svg {
  display: block;
  width: 100%;
  min-width: 540px;
  height: auto;
}

.chart-svg text {
  font-family: var(--font);
}

.chart-axis {
  fill: var(--muted-2);
  font-size: 10.5px;
}

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

.chart-bar-under {
  fill: #74a98b;
}

.chart-bar-over {
  fill: #d9a04b;
}

.chart-target {
  fill: none;
  stroke: #9aa99d;
  stroke-width: 1.4;
  stroke-dasharray: 4 4;
}

.chart-line {
  fill: none;
  stroke: var(--primary);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart-area {
  fill: url("#weightArea");
  opacity: 0.5;
}

.chart-dot {
  fill: var(--surface);
  stroke: var(--primary);
  stroke-width: 2;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 0 20px 16px;
  color: var(--muted);
  font-size: 11px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-swatch {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  background: var(--primary);
}

.legend-swatch.amber {
  background: var(--carbs);
}

.legend-swatch.line {
  width: 14px;
  height: 0;
  border-radius: 0;
  border-top: 2px dashed #9aa99d;
  background: none;
}

.legend-swatch.weight {
  width: 14px;
  height: 0;
  border-radius: 0;
  border-top: 2px solid var(--primary);
  background: none;
}

.empty-state {
  padding: 42px 24px;
  text-align: center;
  color: var(--muted);
}

.empty-state-icon {
  width: 50px;
  height: 50px;
  margin: 0 auto 12px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-size: 22px;
}

.empty-state h3 {
  color: var(--ink);
  font-size: 16px;
}

.empty-state p {
  max-width: 44ch;
  margin: 5px auto 0;
  font-size: 12.5px;
}

.empty-state .btn {
  margin-top: 15px;
}

/* ---------------- 设置 ---------------- */

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.settings-card {
  padding: 20px 21px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.settings-card.wide {
  grid-column: 1 / -1;
}

.settings-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.settings-head h2 {
  font-size: 15.5px;
}

.settings-head p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11.5px;
}

.settings-section {
  padding-top: 14px;
  margin-top: 14px;
  border-top: 1px dashed var(--line);
}

.settings-section:first-of-type {
  padding-top: 0;
  margin-top: 0;
  border-top: 0;
}

.key-row {
  display: flex;
  gap: 7px;
  align-items: stretch;
}

.key-row .input {
  flex: 1;
  min-width: 0;
}

.quota-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 11.5px;
}

.quota-line strong {
  color: var(--ink-soft);
  font-weight: 600;
}

.data-list {
  display: grid;
  margin-top: 12px;
  border-top: 1px solid var(--line);
}

.data-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
}

.data-row:last-child {
  border-bottom: 0;
}

.data-row-main {
  flex: 1;
  min-width: 0;
}

.data-row-title {
  font-weight: 600;
}

.data-row-sub {
  color: var(--muted);
  font-size: 11px;
}

.data-row-value {
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.data-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.about-list {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.about-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 7px;
  border-bottom: 1px dashed var(--line);
}

.about-list div:last-child {
  border-bottom: 0;
}

.about-list strong {
  color: var(--ink-soft);
  font-weight: 600;
}

/* ---------------- 弹窗 ---------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(19, 33, 25, 0.44);
  backdrop-filter: blur(5px);
  animation: backdrop-in 0.16s ease both;
}

@keyframes backdrop-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal {
  width: min(560px, 100%);
  max-height: min(89vh, 920px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 21px;
  background: var(--surface);
  box-shadow: 0 30px 80px rgba(14, 31, 21, 0.24);
  animation: modal-in 0.22s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.modal.wide {
  width: min(690px, 100%);
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.modal-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 20px 22px 13px;
  border-bottom: 1px solid var(--line);
}

.modal-head-copy {
  flex: 1;
  min-width: 0;
}

.modal-title {
  margin-top: 2px;
  font-size: 19px;
  line-height: 1.3;
}

.modal-head .icon-btn {
  margin: -3px -5px 0 0;
}

.modal-body {
  padding: 17px 22px;
  overflow-y: auto;
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 13px 22px 17px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.modal-foot .btn {
  min-width: 88px;
}

.modal-intro {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
}

.tabs {
  display: flex;
  gap: 3px;
  padding: 3px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-3);
}

.tab {
  flex: 1;
  min-height: 33px;
  padding: 5px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
}

.tab:hover {
  color: var(--ink);
}

.tab.active {
  background: var(--surface);
  color: var(--primary-strong);
  box-shadow: 0 2px 7px rgba(25, 47, 34, 0.08);
}

.search-bar {
  display: flex;
  gap: 7px;
}

.search-bar .input {
  flex: 1;
  min-width: 0;
}

.search-status {
  margin-top: 10px;
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
}

.search-status.error {
  color: var(--danger);
}

.search-status.loading {
  color: var(--primary-strong);
}

.food-result {
  margin-top: 10px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-3);
}

.food-result.selected {
  border-color: #b9d7c4;
  background: var(--primary-wash);
}

.food-result-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.food-result-name {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
}

.food-result-type {
  color: var(--muted);
  font-size: 11px;
}

.food-result-badge {
  margin-left: auto;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.food-result-badge.cache {
  background: var(--amber-soft);
  color: #8c5c14;
}

.food-result-macros {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.food-result-note {
  margin-top: 6px;
  color: var(--primary-strong);
  font-size: 11px;
}

.food-result .btn {
  margin-top: 9px;
}

.preview-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  background: var(--surface-3);
}

.preview-kcal {
  font-size: 17px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.preview-kcal small {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 500;
}

.preview-macros {
  color: var(--muted);
  font-size: 11px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.amount-grid {
  display: grid;
  grid-template-columns: 1fr 1.35fr;
  gap: 10px;
  margin-top: 14px;
}

.entry-fields {
  padding-top: 14px;
  margin-top: 14px;
  border-top: 1px dashed var(--line);
}

.entry-fields .form-grid {
  margin-bottom: 12px;
}

/* ---------------- 轻提示 ---------------- */

.toast-root {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(480px, calc(100vw - 32px));
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  max-width: 100%;
  padding: 10px 15px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 11px;
  background: #223a2d;
  color: #f4faf5;
  font-size: 12.5px;
  line-height: 1.45;
  box-shadow: 0 10px 28px rgba(14, 31, 21, 0.2);
  animation: toast-in 0.2s ease both;
}

.toast.error {
  background: #6d2e28;
}

.toast.leaving {
  animation: toast-out 0.2s ease both;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes toast-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
    transform: translateY(5px);
  }
}

.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  margin-top: 30px;
  padding-top: 17px;
  border-top: 1px solid var(--line);
  color: var(--muted-2);
  font-size: 11px;
}

.footer strong {
  color: var(--muted);
  font-weight: 600;
}

/* ---------------- 响应式 ---------------- */

@media (max-width: 1020px) {
  .today-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .side-col {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .settings-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .settings-card.wide {
    grid-column: auto;
  }
}

@media (max-width: 820px) {
  .summary-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .side-col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat-cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

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

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 18px;
  }

  .brand h1 {
    font-size: 17px;
  }

  .main-nav {
    width: 100%;
  }

  .nav-btn {
    flex: 1;
    padding: 8px 10px;
    text-align: center;
  }

  .view-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 11px;
  }

  .view-title {
    font-size: 22px;
  }

  .date-bar {
    width: 100%;
  }

  .date-input {
    flex: 1;
    text-align: center;
  }

  .intake-body {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
    padding: 18px;
  }

  .ring-wrap {
    width: 156px;
    height: 156px;
    align-self: center;
  }

  .intake-copy {
    text-align: center;
  }

  .remaining-line {
    justify-content: center;
  }

  .intake-note {
    margin-left: auto;
    margin-right: auto;
  }

  .mini-chips {
    justify-content: center;
  }

  .plan-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .metric {
    padding: 9px;
  }

  .metric-value {
    font-size: 15px;
  }

  .panel-head {
    padding: 17px 17px 0;
  }

  .log-list {
    padding: 11px 13px 15px;
  }

  .side-col {
    grid-template-columns: minmax(0, 1fr);
  }

  .stat-cards {
    grid-template-columns: minmax(0, 1fr);
    gap: 9px;
  }

  .stat-card {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    padding: 13px 15px;
  }

  .stat-card-value {
    margin-top: 0;
    font-size: 21px;
  }

  .stat-card-sub {
    display: none;
  }

  .settings-card {
    padding: 17px;
  }

  .form-grid,
  .form-grid.three {
    grid-template-columns: minmax(0, 1fr);
  }

  .form-grid .span-2 {
    grid-column: auto;
  }

  .amount-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .modal-backdrop {
    padding: 0;
    align-items: flex-end;
  }

  .modal {
    width: 100%;
    max-height: 92vh;
    border-radius: 20px 20px 0 0;
    animation-name: modal-up;
  }

  .modal.wide {
    width: 100%;
  }

  @keyframes modal-up {
    from {
      opacity: 0;
      transform: translateY(30px);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }

  .modal-head,
  .modal-body,
  .modal-foot {
    padding-left: 17px;
    padding-right: 17px;
  }

  .modal-foot .btn {
    flex: 1;
  }

  .footer {
    margin-top: 22px;
  }
}

@media (max-width: 420px) {
  .plan-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .metric-label {
    font-size: 10px;
  }

  .metric-value {
    font-size: 13px;
    white-space: nowrap;
  }

  .metric-value small {
    display: block;
    margin-top: 1px;
    font-size: 10px;
  }

  .weight-prompt form {
    width: 100%;
  }

  .weight-prompt .field {
    flex: 1;
  }
}

/* ---------------- 轻玻璃与微动效 ---------------- */

/* 只让信息层级最高的面板透出背景，记录与图表保持更实、更易读 */
.intake-panel,
.plan-panel,
.side-card,
.modal {
  background: var(--glass-bg);
  border-color: var(--glass-border);
  box-shadow: var(--glass-shadow);
  -webkit-backdrop-filter: blur(18px) saturate(145%);
  backdrop-filter: blur(18px) saturate(145%);
}

.main-nav {
  border-color: var(--glass-border);
  background: rgba(255, 255, 255, 0.56);
  box-shadow: 0 8px 24px rgba(35, 74, 52, 0.06);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  backdrop-filter: blur(18px) saturate(150%);
}

.nav-btn.active {
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 3px 10px rgba(25, 47, 34, 0.09);
}

.btn.primary {
  background: linear-gradient(135deg, #2f7d5b 0%, #3d956b 48%, #2f7d5b 100%);
  background-size: 180% 180%;
  background-position: 0 0;
  box-shadow: 0 8px 18px rgba(47, 125, 91, 0.22);
}

.btn.primary:hover {
  background-position: 100% 0;
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 11px 24px rgba(47, 125, 91, 0.27);
}

.btn.primary:active {
  transform: translateY(0);
}

.ring-value {
  stroke: url(#ring-gradient);
  stroke-dasharray: var(--ring-circ);
  stroke-dashoffset: var(--ring-offset);
  animation: ring-draw 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.ring-value.over {
  stroke: url(#ring-gradient-over);
}

@keyframes ring-draw {
  from {
    stroke-dashoffset: var(--ring-circ);
  }
  to {
    stroke-dashoffset: var(--ring-offset);
  }
}

@media (hover: hover) and (pointer: fine) {
  .intake-panel,
  .plan-panel,
  .side-card {
    transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
  }

  .intake-panel:hover,
  .plan-panel:hover,
  .side-card:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.92);
    box-shadow: var(--shadow-hover);
  }
}

@media (max-width: 680px) {
  .intake-panel,
  .plan-panel,
  .side-card,
  .modal {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.7));
    -webkit-backdrop-filter: blur(12px) saturate(135%);
    backdrop-filter: blur(12px) saturate(135%);
  }

  .ambient {
    opacity: 0.8;
  }
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .intake-panel,
  .plan-panel,
  .side-card,
  .modal,
  .main-nav {
    background: var(--surface);
  }
}

.flash {
  animation: flash-ring 1.2s ease;
}

@keyframes flash-ring {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(47, 125, 91, 0);
  }
  25% {
    box-shadow: 0 0 0 5px rgba(47, 125, 91, 0.3);
  }
  60% {
    box-shadow: 0 0 0 5px rgba(47, 125, 91, 0.12);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
