/* 食刻 · 移动端样式
   配色走「米饭 + 陶土」的暖色系，浅色/深色各一套 */

:root {
  color-scheme: light dark;
  --bg: #f6f4ef;
  --bg-deep: #ece7dd;
  --card: #ffffff;
  --card-2: #fbf9f5;
  --text: #1c1a17;
  --text-2: #4a453d;
  --sub: #7b746a;
  --line: #eae4d9;
  --soft: #f7f3ec;
  --accent: #e8734a;
  --accent-2: #f2a65a;
  --accent-soft: #fdece4;
  --green: #5b8c5a;
  --yellow: #c99a3e;
  --red: #c0573f;
  --danger: #d9564b;
  --shadow: 0 1px 2px rgba(60, 40, 20, 0.04), 0 10px 26px -18px rgba(60, 40, 20, 0.22);
  --radius: 20px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141210;
    --bg-deep: #0d0c0a;
    --card: #1e1b18;
    --card-2: #221f1b;
    --text: #f4efe6;
    --text-2: #d9d1c4;
    --sub: #a69d90;
    --line: #2c2721;
    --soft: #26221d;
    --accent: #ff8a5c;
    --accent-2: #f2a65a;
    --accent-soft: #37241b;
    --green: #7fae72;
    --yellow: #d9b25c;
    --red: #e0705f;
    --danger: #ef6a5c;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 30px -20px rgba(0, 0, 0, 0.8);
  }
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'HarmonyOS Sans SC', 'MiSans',
    'Microsoft YaHei', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body.lock {
  overflow: hidden;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

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

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

h1 {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: 0.02em;
}

h2 {
  font-size: 16px;
  font-weight: 650;
}

h3 {
  font-size: 15px;
  font-weight: 600;
}

::selection {
  background: var(--accent-soft);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.ic {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.ic.tiny {
  width: 13px;
  height: 13px;
  opacity: 0.45;
}

.ic.sm {
  width: 16px;
  height: 16px;
}

/* ---------------- 应用骨架 ---------------- */

body {
  display: flex;
  justify-content: center;
}

.app {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 520px;
  height: 100dvh;
  background: var(--bg);
  overflow: hidden;
}

@media (min-width: 560px) {
  .app {
    height: calc(100dvh - 32px);
    margin: 16px 0;
    border-radius: 28px;
    box-shadow: 0 30px 80px -40px rgba(50, 30, 10, 0.4), 0 0 0 1px var(--line);
  }
}

.appbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 18px 10px;
  flex: none;
}

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

.logo {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(140deg, #fff3e6, #ffe0cc);
  font-size: 20px;
  box-shadow: inset 0 0 0 1px rgba(232, 115, 74, 0.16);
}

@media (prefers-color-scheme: dark) {
  .logo {
    background: linear-gradient(140deg, #3a2a1f, #33231a);
  }
}

.brand p {
  color: var(--sub);
  font-size: 12px;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: var(--text-2);
  transition: background 0.18s, color 0.18s;
  flex: none;
}

.icon-btn:hover {
  background: var(--soft);
  color: var(--text);
}

.icon-btn.danger {
  color: var(--sub);
}

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

.main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 16px 24px;
  scrollbar-width: thin;
}

.main::-webkit-scrollbar {
  width: 0;
}

.view {
  display: none;
  padding-bottom: 8px;
  animation: fade-in 0.24s ease;
}

.view.active {
  display: block;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

/* ---------------- 底栏 ---------------- */

.tabbar {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
  flex: none;
  padding: 6px 6px calc(6px + var(--safe-b));
  background: color-mix(in srgb, var(--card) 88%, transparent);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 0;
  color: var(--sub);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  transition: color 0.18s;
}

.tab .ic {
  width: 22px;
  height: 22px;
}

.tab.active {
  color: var(--accent);
}

.tab.active .ic {
  stroke-width: 2.2;
}

.tab-shot {
  position: relative;
  width: 58px;
  height: 58px;
  margin: -22px auto 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(150deg, var(--accent-2), var(--accent));
  box-shadow: 0 10px 22px -8px rgba(232, 115, 74, 0.65), inset 0 0 0 4px var(--card);
  transition: transform 0.16s;
}

.tab-shot .ic {
  width: 26px;
  height: 26px;
  stroke-width: 2;
}

.tab-shot:active {
  transform: scale(0.94);
}

/* ---------------- 通用卡片 ---------------- */

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

.muted {
  color: var(--sub);
}

.small {
  font-size: 12px;
}

.eyebrow {
  color: var(--sub);
  font-size: 12px;
  letter-spacing: 0.06em;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 22px 4px 10px;
}

.section-head h2 {
  font-size: 15px;
  letter-spacing: 0.03em;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 48px;
  border-radius: 15px;
  background: linear-gradient(150deg, var(--accent-2), var(--accent));
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  box-shadow: 0 8px 20px -10px rgba(232, 115, 74, 0.8);
  transition: transform 0.16s, opacity 0.2s;
}

.btn-primary:active {
  transform: scale(0.985);
}

.btn-primary:disabled {
  opacity: 0.45;
  box-shadow: none;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text-2);
  font-size: 13.5px;
  transition: background 0.18s;
}

.btn-ghost:hover {
  background: var(--soft);
}

.btn-ghost:disabled {
  opacity: 0.5;
}

.text-btn {
  color: var(--accent);
  font-size: 13px;
  font-weight: 550;
  padding: 4px 2px;
}

.badge {
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--sub);
  font-size: 11.5px;
}

.badge.ok {
  background: var(--accent-soft);
  color: var(--accent);
}

.hint {
  color: var(--sub);
  font-size: 12.5px;
  line-height: 1.55;
  margin-top: 8px;
}

.foot-note {
  text-align: center;
  font-size: 12px;
  margin: 22px 0 6px;
}

/* ---------------- 今日 ---------------- */

.hero {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px;
  margin-top: 4px;
  background: linear-gradient(135deg, var(--accent-soft), var(--card) 62%);
}

.ring-wrap {
  position: relative;
  width: 122px;
  height: 122px;
  flex: none;
}

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

.ring-track {
  fill: none;
  stroke: color-mix(in srgb, var(--line) 82%, transparent);
  stroke-width: 9;
}

.ring-bar {
  fill: none;
  stroke-width: 9;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.ring-center b {
  font-size: 27px;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}

.ring-center span {
  font-size: 11px;
  color: var(--sub);
  margin-top: 2px;
}

.hero-info {
  min-width: 0;
  flex: 1;
}

.hero-left {
  margin-top: 6px;
  font-size: 15px;
  color: var(--text-2);
}

.hero-left b {
  font-size: 21px;
  font-weight: 650;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.hero-left.over b {
  color: var(--danger);
}

.hero-sub {
  margin-top: 4px;
  font-size: 12px;
  color: var(--sub);
}

.macro-card {
  margin-top: 12px;
  padding: 16px 18px;
  display: grid;
  gap: 12px;
}

.macro-row {
  display: grid;
  grid-template-columns: 58px 1fr auto;
  align-items: center;
  gap: 10px;
}

.macro-name {
  font-size: 12.5px;
  color: var(--text-2);
}

.bar {
  height: 7px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--line) 70%, transparent);
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  border-radius: 99px;
  transition: width 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.macro-val {
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
  min-width: 76px;
  text-align: right;
}

.macro-val em {
  font-style: normal;
  color: var(--sub);
  font-size: 11.5px;
}

.empty {
  padding: 34px 22px 30px;
  text-align: center;
}

.empty.small {
  padding: 22px;
}

.empty-emoji {
  font-size: 44px;
  line-height: 1;
  margin-bottom: 12px;
  filter: saturate(0.9);
}

.empty h3 {
  margin-bottom: 6px;
}

.empty p {
  font-size: 13px;
  margin-bottom: 18px;
}

.empty .btn-primary {
  max-width: 240px;
  margin: 0 auto;
}

/* ---------------- 餐次卡片 ---------------- */

.meal-group {
  margin-bottom: 14px;
}

.group-head {
  display: flex;
  justify-content: space-between;
  padding: 0 6px 7px;
  font-size: 12px;
  color: var(--sub);
}

.meal-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: transform 0.14s, border-color 0.18s;
}

.meal-card:active {
  transform: scale(0.994);
}

.meal-card:hover {
  border-color: color-mix(in srgb, var(--accent) 26%, var(--line));
}

.meal-thumb {
  width: 54px;
  height: 54px;
  border-radius: 13px;
  overflow: hidden;
  flex: none;
  background: var(--soft);
  display: grid;
  place-items: center;
  font-size: 24px;
}

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

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

.meal-main h3 {
  font-size: 14.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meal-meta {
  font-size: 11.5px;
  color: var(--sub);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meal-right {
  display: flex;
  align-items: baseline;
  gap: 2px;
  flex: none;
  font-variant-numeric: tabular-nums;
}

.meal-right b {
  font-size: 17px;
  font-weight: 650;
}

.meal-right span {
  font-size: 10.5px;
  color: var(--sub);
}

.meal-del {
  width: 28px;
  height: 28px;
  margin-left: -4px;
  opacity: 0.5;
}

.meal-del .ic {
  width: 15px;
  height: 15px;
}

@media (hover: hover) {
  .meal-del {
    opacity: 0;
  }
  .meal-card:hover .meal-del {
    opacity: 0.6;
  }
}

/* ---------------- 记录 ---------------- */

.day-strip {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 4px 2px 12px;
  scrollbar-width: none;
  scroll-behavior: smooth;
}

.day-strip::-webkit-scrollbar {
  display: none;
}

.day-chip {
  flex: none;
  width: 48px;
  padding: 8px 0 6px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--card);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  color: var(--sub);
  transition: background 0.18s, color 0.18s, border-color 0.18s;
}

.day-chip .dow {
  font-size: 10px;
}

.day-chip .num {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.day-chip .dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  margin-top: 3px;
  background: transparent;
}

.day-chip .dot.on {
  background: var(--accent);
}

.day-chip.active {
  background: linear-gradient(155deg, var(--accent-2), var(--accent));
  border-color: transparent;
  color: rgba(255, 255, 255, 0.85);
}

.day-chip.active .num {
  color: #fff;
}

.day-chip.active .dot.on {
  background: #fff;
}

.day-summary {
  padding: 16px 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 14px;
}

.sum-kcal b {
  font-size: 25px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.sum-kcal span {
  color: var(--sub);
  font-size: 12.5px;
}

.sum-macros {
  display: flex;
  gap: 12px;
  font-size: 11.5px;
  color: var(--sub);
  flex-wrap: wrap;
}

/* ---------------- 统计 ---------------- */

.chart-card {
  padding: 18px 16px 12px;
}

.chart {
  position: relative;
  height: 172px;
  margin-bottom: 26px;
}

.goal-line {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px dashed color-mix(in srgb, var(--accent) 55%, transparent);
  z-index: 2;
}

.goal-line span {
  position: absolute;
  right: 2px;
  top: -17px;
  font-size: 10.5px;
  color: var(--accent);
  background: var(--card);
  padding: 0 4px;
  border-radius: 4px;
}

.chart-bars {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 100%;
}

.chart-col {
  flex: 1;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  position: relative;
}

.chart-bar {
  position: relative;
  width: 70%;
  max-width: 36px;
  min-height: 2px;
  border-radius: 7px 7px 5px 5px;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  transition: height 0.5s ease;
}

.chart-col.empty .chart-bar {
  background: var(--line);
  border-radius: 4px;
}

.chart-bar i {
  position: absolute;
  top: -19px;
  left: 50%;
  transform: translateX(-50%);
  font-style: normal;
  font-size: 10.5px;
  color: var(--sub);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.chart-x {
  position: absolute;
  bottom: -22px;
  font-size: 10.5px;
  color: var(--sub);
  white-space: nowrap;
}

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

.tile {
  padding: 15px 8px;
  text-align: center;
}

.tile b {
  display: block;
  font-size: 22px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.tile span {
  font-size: 11px;
  color: var(--sub);
}

.insight {
  margin-top: 12px;
  padding: 15px 18px;
  background: var(--accent-soft);
  border-color: transparent;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-2);
}

/* ---------------- 我的 ---------------- */

.profile {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  margin-top: 4px;
}

.avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 25px;
  background: linear-gradient(150deg, #fff2e2, #ffdcc4);
  flex: none;
}

@media (prefers-color-scheme: dark) {
  .avatar {
    background: linear-gradient(150deg, #3b2a1e, #33231a);
  }
}

.profile h2 {
  font-size: 16px;
}

.profile p {
  font-size: 12px;
  margin-top: 2px;
}

#view-me > .card {
  margin-top: 12px;
  padding: 16px 18px;
}

.filemode {
  background: var(--accent-soft);
  border-color: transparent;
}

.filemode b {
  font-size: 13.5px;
}

.filemode .hint {
  margin-top: 5px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.goal-inputs {
  display: grid;
  gap: 9px;
}

.goal-inputs label,
.smart-grid label {
  display: grid;
  grid-template-columns: 64px 1fr 34px;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  color: var(--sub);
}

.goal-inputs em,
.smart-grid em {
  font-style: normal;
  font-size: 11.5px;
  color: var(--sub);
}

.input {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--text);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.18s, background 0.18s;
}

.input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  background: var(--card);
}

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

.smart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px 10px;
  margin-bottom: 12px;
}

.smart-grid label {
  grid-template-columns: 56px 1fr 26px;
}

.smart-grid label.wide {
  grid-column: 1 / -1;
  grid-template-columns: 70px 1fr;
}

.smart-panel .btn-primary {
  height: 42px;
  font-size: 14px;
}

.field {
  display: block;
  margin-top: 10px;
}

.field > span {
  display: block;
  font-size: 12px;
  color: var(--sub);
  margin-bottom: 5px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 4px;
}

.chip {
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
  transition: background 0.16s, color 0.16s, border-color 0.16s;
}

.chip.active {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
  color: var(--accent);
  font-weight: 550;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 14px;
  font-size: 13px;
}

.switch-row span {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.switch-row em {
  font-style: normal;
  font-size: 11.5px;
  color: var(--sub);
  line-height: 1.45;
}

.switch-row input[type='checkbox'] {
  appearance: none;
  -webkit-appearance: none;
  width: 46px;
  height: 27px;
  border-radius: 99px;
  background: var(--line);
  position: relative;
  flex: none;
  transition: background 0.2s;
  cursor: pointer;
}

.switch-row input[type='checkbox']::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s;
}

.switch-row input[type='checkbox']:checked {
  background: var(--accent);
}

.switch-row input[type='checkbox']:checked::after {
  transform: translateX(19px);
}

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

#aiStatus {
  flex: 1;
  min-width: 120px;
  line-height: 1.4;
}

.list-actions {
  margin: 6px -18px -16px;
}

.row-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 18px;
  text-align: left;
  border-top: 1px solid var(--line);
  color: var(--text-2);
  transition: background 0.16s;
}

.row-btn:hover {
  background: var(--soft);
}

.row-btn .ic {
  color: var(--sub);
}

.row-btn span {
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: 14px;
}

.row-btn em {
  font-style: normal;
  font-size: 11.5px;
  color: var(--sub);
}

.row-btn.danger,
.row-btn.danger .ic {
  color: var(--danger);
}

.about {
  padding-bottom: 18px;
}

.about .btn-ghost {
  margin-top: 12px;
}

/* ---------------- 底部面板 ---------------- */

.sheet-mask {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(20, 14, 8, 0.42);
  opacity: 0;
  transition: opacity 0.22s ease;
  backdrop-filter: blur(2px);
}

.sheet-mask.open {
  opacity: 1;
}

.sheet {
  width: 100%;
  max-width: 520px;
  background: var(--card);
  border-radius: 26px 26px 0 0;
  padding: 10px 18px calc(18px + var(--safe-b));
  box-shadow: 0 -20px 50px -20px rgba(0, 0, 0, 0.35);
  transform: translateY(12px);
  transition: transform 0.26s cubic-bezier(0.2, 0.8, 0.2, 1);
  max-height: 86dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sheet-mask.open .sheet {
  transform: none;
}

.sheet.tall {
  height: 82dvh;
  padding-top: 8px;
}

.sheet-grip {
  width: 38px;
  height: 4px;
  border-radius: 99px;
  background: var(--line);
  margin: 0 auto 14px;
  flex: none;
}

.sheet h3 {
  font-size: 17px;
  margin-bottom: 4px;
}

.sheet-desc {
  font-size: 12.5px;
  color: var(--sub);
  margin-bottom: 14px;
}

.sheet-action {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  padding: 11px 12px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--card);
  margin-bottom: 9px;
  text-align: left;
  cursor: pointer;
  transition: background 0.16s, border-color 0.16s;
}

.sheet-action:hover {
  background: var(--soft);
}

.sa-icon {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 20px;
  flex: none;
}

.sa-icon.alt {
  background: color-mix(in srgb, var(--green) 14%, var(--card));
}

.sa-icon.alt2 {
  background: var(--soft);
}

.sheet-action b {
  display: block;
  font-size: 14.5px;
  font-weight: 600;
}

.sheet-action i {
  display: block;
  font-style: normal;
  font-size: 11.5px;
  color: var(--sub);
  margin-top: 1px;
}

.sheet-cancel {
  width: 100%;
  height: 44px;
  margin-top: 5px;
  border-radius: 14px;
  color: var(--sub);
  font-size: 14px;
}

.sheet-cancel:hover {
  background: var(--soft);
}

/* ---------------- 食物库 ---------------- */

.search-head {
  flex: none;
  padding: 2px 0 10px;
}

.search-head input {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--soft);
  font-size: 14px;
}

.search-head input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  background: var(--card);
}

.cat-chips {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 0 0 10px;
  flex: none;
  scrollbar-width: none;
}

.cat-chips::-webkit-scrollbar {
  display: none;
}

.food-results {
  flex: 1;
  overflow-y: auto;
  margin: 0 -18px;
  padding-bottom: 8px;
  overscroll-behavior: contain;
}

.food-row {
  display: grid;
  grid-template-columns: 30px 1fr auto 26px;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 18px;
  text-align: left;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 65%, transparent);
  transition: background 0.14s;
}

.food-row:hover {
  background: var(--soft);
}

.food-emoji {
  font-size: 18px;
  text-align: center;
}

.food-name {
  display: flex;
  flex-direction: column;
  font-size: 14px;
  min-width: 0;
}

.food-name em {
  font-style: normal;
  font-size: 11px;
  color: var(--sub);
}

.food-kcal {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-size: 13px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.food-kcal em {
  font-style: normal;
  font-size: 10px;
  color: var(--sub);
}

.food-add {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
}

.food-add .ic {
  width: 15px;
  height: 15px;
}

.pad {
  padding: 24px 18px;
  text-align: center;
}

/* ---------------- 识别页 ---------------- */

.analyzer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.analyzer.open {
  transform: none;
}

.analyzer-bar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 8px;
  flex: none;
}

.an-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 15px;
  font-weight: 600;
  pointer-events: none;
}

.analyzer-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 16px;
  overscroll-behavior: contain;
}

.photo-wrap {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  background: var(--soft);
  aspect-ratio: 4 / 3;
  margin-bottom: 14px;
  display: none;
}

.photo-wrap.has-photo {
  display: block;
}

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

.scan {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 38%;
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.16) 60%, rgba(255, 255, 255, 0.55));
  border-bottom: 2px solid rgba(255, 255, 255, 0.85);
  opacity: 0;
  pointer-events: none;
}

.photo-wrap.scanning .scan {
  opacity: 1;
  animation: scanning 1.7s ease-in-out infinite;
}

@keyframes scanning {
  0% {
    transform: translateY(-60%);
  }
  50% {
    transform: translateY(160%);
  }
  100% {
    transform: translateY(-60%);
  }
}

.photo-badge {
  position: absolute;
  left: 10px;
  bottom: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(20, 14, 8, 0.55);
  color: #fff;
  font-size: 11px;
  backdrop-filter: blur(6px);
}

.analyzer-foot {
  flex: none;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px calc(12px + var(--safe-b));
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(16px);
}

.foot-total {
  flex: none;
  min-width: 96px;
}

.foot-total b {
  font-size: 24px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.foot-total span {
  font-size: 11px;
  color: var(--sub);
  margin-left: 3px;
}

.foot-total em {
  display: block;
  font-style: normal;
  font-size: 10.5px;
  color: var(--sub);
  margin-top: 1px;
  white-space: nowrap;
}

.analyzer-foot .btn-primary {
  flex: 1;
  width: auto;
}

.mealtype-row {
  display: flex;
  gap: 7px;
  margin-bottom: 12px;
  overflow-x: auto;
  scrollbar-width: none;
}

.mealtype-row::-webkit-scrollbar {
  display: none;
}

.dish-name {
  font-size: 13px;
  color: var(--sub);
  margin: 2px 4px 10px;
}

.an-list {
  display: grid;
  gap: 9px;
}

.an-item {
  padding: 12px 14px 10px;
}

.an-item-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.name-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 1;
  min-width: 0;
  font-size: 14.5px;
  font-weight: 600;
  text-align: left;
  border-bottom: 1px dashed transparent;
}

.name-btn:hover {
  border-bottom-color: var(--line);
}

.name-btn .est {
  font-size: 9px;
  font-weight: 500;
  color: var(--sub);
  background: var(--soft);
  border-radius: 4px;
  padding: 0 3px;
  line-height: 1.5;
}

.kcal-badge {
  font-size: 11px;
  color: var(--sub);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.kcal-badge b {
  font-size: 16px;
  color: var(--text);
}

.grams-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 4px;
}

.step {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--soft);
  display: grid;
  place-items: center;
  font-size: 15px;
  color: var(--text-2);
  flex: none;
}

.step:active {
  background: var(--accent-soft);
}

.grams-main {
  display: flex;
  align-items: baseline;
  gap: 4px;
  flex: 1;
}

.grams-main input {
  width: 68px;
  height: 32px;
  padding: 0 8px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--card);
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.grams-main input:focus {
  outline: none;
  border-color: var(--accent);
}

.grams-main span {
  font-size: 11px;
  color: var(--sub);
}

.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 24px;
  margin: 4px 0 0;
  background: transparent;
  accent-color: var(--accent);
}

.slider::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--line) 85%, transparent);
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -7px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--card);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
  cursor: pointer;
}

.slider::-moz-range-track {
  height: 6px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--line) 85%, transparent);
}

.slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--card);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
  cursor: pointer;
}

.macro-line {
  font-size: 11px;
  color: var(--sub);
  margin-top: 2px;
}

.add-item {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  height: 46px;
  margin-top: 11px;
  border-radius: 14px;
  border: 1px dashed color-mix(in srgb, var(--accent) 40%, var(--line));
  color: var(--accent);
  font-size: 14px;
  font-weight: 550;
  background: color-mix(in srgb, var(--accent-soft) 45%, transparent);
}

.an-loading,
.an-error {
  padding: 26px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.an-loading .row-actions,
.an-error .row-actions {
  justify-content: center;
}

.dots {
  display: flex;
  gap: 6px;
  margin-bottom: 4px;
}

.dots i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: blink 1.2s infinite ease-in-out;
}

.dots i:nth-child(2) {
  animation-delay: 0.18s;
}

.dots i:nth-child(3) {
  animation-delay: 0.36s;
}

@keyframes blink {
  0%,
  80%,
  100% {
    opacity: 0.25;
    transform: scale(0.8);
  }
  40% {
    opacity: 1;
    transform: scale(1);
  }
}

/* ---------------- Toast ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-b));
  z-index: 80;
  transform: translate(-50%, 10px);
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(28, 24, 19, 0.92);
  color: #fff;
  font-size: 12.5px;
  max-width: 82vw;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s, transform 0.22s;
  backdrop-filter: blur(8px);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (prefers-color-scheme: dark) {
  .toast {
    background: rgba(240, 235, 226, 0.95);
    color: #1b1815;
  }
}

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