/* ============================================================
   每日工作台 · 设计系统（绿 + 蓝）
   ============================================================ */
:root {
  /* 主色 · 青绿 */
  --brand-700:#0B6E63; --brand-600:#12907F; --brand-500:#18A793; --brand-300:#6FCFC0;
  --brand-100:#CBEDE7; --brand-050:#E8F6F3;
  /* 辅助 · 蓝 */
  --blue-600:#1F6FB2; --blue-500:#2E8BD4; --blue-100:#D6E9F8; --blue-050:#EAF3FB;
  /* 背景 */
  --bg-grad:linear-gradient(135deg,#EAF7F4 0%,#E9F3FA 52%,#EDF7F3 100%);
  --bg-app:#F4FAF9;
  /* 面 */
  --card:#FFFFFF; --card-alt:#F7FCFB;
  --line:#DBE9E7; --line-blue:#D8E6F2;
  /* 文字 */
  --text-900:#123039; --text-600:#4C6672; --text-400:#8AA2AB; --text-invert:#FFFFFF;
  /* 语义（涨红跌绿） */
  --up:#E23B3B; --down:#12A05C; --flat:#7A8C94;
  --expense:#D9534F; --income:#12907F;
  --warn:#E8A33D; --danger:#D64545;
  /* 渐变 */
  --grad-brand:linear-gradient(135deg,#12907F 0%,#2E8BD4 100%);
  --grad-chip:linear-gradient(135deg,#18A793 0%,#2E8BD4 100%);
  --grad-soft:linear-gradient(135deg,#E8F6F3 0%,#EAF3FB 100%);
  /* 字体 */
  --font:"Microsoft YaHei UI","Microsoft YaHei","PingFang SC","Segoe UI",system-ui,sans-serif;
  --font-num:"Consolas","JetBrains Mono",ui-monospace,monospace;
  /* 间距 */
  --sp-1:4px; --sp-2:8px; --sp-3:12px; --sp-4:16px; --sp-5:20px; --sp-6:24px; --sp-8:32px;
  /* 圆角 */
  --r-sm:8px; --r-md:12px; --r-lg:16px; --r-xl:20px; --r-full:999px;
  /* 阴影 */
  --sh-card:0 2px 12px rgba(14,90,82,.08);
  --sh-hover:0 6px 20px rgba(14,90,82,.14);
  --sh-pop:0 12px 32px rgba(10,60,56,.18);
}

[data-theme="dark"] {
  --bg-app:#0F1B1E; --bg-grad:linear-gradient(135deg,#0F1F1E 0%,#10202A 100%);
  --card:#16262A; --card-alt:#1B2E33;
  --line:#26403F; --line-blue:#27400F;
  --text-900:#E8F3F1; --text-600:#A8C2C6; --text-400:#7A949A;
  --brand-600:#2BB69F; --brand-500:#34C4AC; --brand-300:#3E9E8F;
  --brand-100:#1E3B3A; --brand-050:#162A29;
  --blue-500:#4AA6E8; --blue-100:#1B3346; --blue-050:#16232E;
  --sh-card:0 2px 12px rgba(0,0,0,.4);
  --sh-hover:0 6px 20px rgba(0,0,0,.5);
}

* { box-sizing:border-box; }
html, body { height:100%; margin:0; }
body {
  font-family:var(--font); font-size:14px; line-height:1.7; color:var(--text-900);
  background:var(--bg-app); background-image:var(--bg-grad); background-attachment:fixed;
  -webkit-font-smoothing:antialiased; overflow:hidden;
}
::-webkit-scrollbar { width:13px; height:13px; }
::-webkit-scrollbar-thumb { background:var(--brand-300); border-radius:var(--r-full); border:3px solid transparent; background-clip:padding-box; }
::-webkit-scrollbar-thumb:hover { background:var(--brand-500); border:3px solid transparent; background-clip:padding-box; }
::-webkit-scrollbar-track { background:transparent; }
::-webkit-scrollbar-corner { background:transparent; }
.ex-img { border-radius:10px; object-fit:cover; background:#fff; box-shadow:var(--sh-card); cursor:zoom-in; }
/* 悬停放大：全屏半透明浮层，原图按比例完整居中显示；pointer-events:none 鼠标穿透防闪烁 */
.ex-zoom {
  position:fixed; inset:0; z-index:9999; background:rgba(15,23,42,.72);
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:10px;
  backdrop-filter:blur(2px);
  pointer-events:none;
}
.ex-zoom img {
  max-width:92vw; max-height:86vh; width:auto; height:auto;
  object-fit:contain; background:#fff; border-radius:12px;
  box-shadow:0 18px 60px rgba(0,0,0,.45);
}
.ex-zoom-cap {
  color:#fff; font-size:13px; background:rgba(0,0,0,.45);
  padding:5px 14px; border-radius:999px;
}

button, input, select, textarea { font-family:inherit; font-size:inherit; color:inherit; }
button { cursor:pointer; border:none; background:none; }
.num { font-family:var(--font-num); font-variant-numeric:tabular-nums; }

/* ---------------- 布局 ---------------- */
.app { display:flex; height:100vh; overflow:hidden; }

.sidebar {
  width:200px; flex:0 0 200px; padding:var(--sp-5) var(--sp-3);
  display:flex; flex-direction:column; gap:var(--sp-2);
  background:rgba(255,255,255,.62); backdrop-filter:blur(8px);
  border-right:1px solid var(--line);
}
[data-theme="dark"] .sidebar { background:rgba(22,38,42,.7); }

.sidebar .brand { display:flex; flex-direction:column; align-items:center; gap:var(--sp-2); padding:var(--sp-2) 0 var(--sp-5); }
.sidebar .avatar {
  width:56px; height:56px; border-radius:50%; display:grid; place-items:center; font-size:26px;
  background:var(--brand-050); border:2px solid var(--brand-100);
}
.sidebar .brand-name { font-size:14px; font-weight:600; color:var(--text-900); }

.nav-item {
  display:flex; align-items:center; gap:var(--sp-3); height:52px; padding:0 var(--sp-4);
  border-radius:var(--r-md); font-size:14px; color:var(--text-600);
  transition:background .15s, color .15s; text-align:left; width:100%;
}
.nav-item .ico { font-size:22px; line-height:1; }
.nav-item:hover { background:var(--brand-050); color:var(--text-900); }
.nav-item.active { background:var(--grad-chip); color:#fff; box-shadow:var(--sh-card); }
.nav-spacer { flex:1; }

.main { flex:1; display:flex; flex-direction:column; min-width:0; overflow:hidden; }
.main-scroll { flex:1; overflow-y:auto; padding:var(--sp-6) var(--sp-8) 0; }
.wrap { max-width:900px; margin:0 auto; padding-bottom:var(--sp-6); }

/* ---------------- 模块头 ---------------- */
.mod-head { display:flex; align-items:center; gap:var(--sp-3); margin-bottom:var(--sp-4); }
.mod-head .m-ico { font-size:26px; line-height:1; }
.mod-head h1 { font-size:22px; font-weight:700; margin:0; line-height:1.3; }
.mod-head .spacer { flex:1; }

/* ---------------- 日期栏 ---------------- */
.datebar { display:flex; align-items:center; gap:var(--sp-3); margin-bottom:var(--sp-3); }
.date-nav {
  width:30px; height:30px; border-radius:50%; display:grid; place-items:center;
  color:var(--brand-600); font-size:13px;
}
.date-nav:hover { background:var(--brand-050); }
.date-nav:disabled { color:var(--text-400); opacity:.4; cursor:not-allowed; }
.date-label { font-size:15px; font-weight:600; color:var(--brand-700); }
.datebar .spacer { flex:1; }

.btn-pill {
  height:32px; padding:0 var(--sp-4); border-radius:var(--r-full); font-size:12px;
  background:var(--brand-050); color:var(--brand-700); transition:.15s;
}
.btn-pill:hover { background:var(--brand-100); }
.btn-pill.on { background:var(--grad-chip); color:#fff; }

.hint {
  font-size:12px; color:var(--text-400); display:flex; gap:6px; align-items:flex-start;
  margin-bottom:var(--sp-4); line-height:1.6;
}
.hint.live { color:var(--brand-600); }

/* ---------------- 卡片 ---------------- */
.card {
  background:var(--card); border-radius:var(--r-lg); padding:var(--sp-5);
  box-shadow:var(--sh-card); margin-bottom:var(--sp-4);
}
.card.soft { background:var(--grad-soft); }
.card-head { display:flex; align-items:center; gap:var(--sp-2); margin-bottom:var(--sp-3); }
.card-head .ico { font-size:18px; line-height:1; }
.card-head h2 { font-size:17px; font-weight:600; margin:0; }
.card-head .sub { font-size:12px; color:var(--text-400); font-weight:400; }
.card-head .spacer { flex:1; }
.subcard { background:var(--card-alt); border-radius:var(--r-md); padding:var(--sp-4); margin-top:var(--sp-3); }
.divider { border-top:1px dashed var(--line); margin:var(--sp-3) 0; }

.list { list-style:none; margin:0; padding:0; }
.list li { position:relative; padding-left:18px; margin-bottom:var(--sp-2); line-height:1.7; }
.list li::before {
  content:''; position:absolute; left:4px; top:.72em; width:6px; height:6px;
  border-radius:50%; background:var(--brand-500);
}
.list li.plain::before { display:none; }
.list.dishes li {
  display:flex; align-items:center; gap:8px; flex-wrap:nowrap;
}
.list.dishes li::before { display:none; }
.list.dishes li .strong-title {
  flex:0 1 auto; min-width:0; white-space:nowrap;
  /* 框固定不动；溢出时由内层 .mq-text 跑马灯滚动，不省略 */
  overflow:hidden;
}
.list.dishes li .tag-nutri { flex:0 0 auto; }
.list.dishes li > .icon-btn { flex:0 0 auto; margin:0; width:26px; height:26px; line-height:26px; padding:0; }

.strong-title { font-weight:600; color:var(--text-900); }
.muted { color:var(--text-600); }
.dim { color:var(--text-400); font-size:13px; }

/* ---------------- 通用控件 ---------------- */
.btn {
  height:36px; padding:0 var(--sp-5); border-radius:var(--r-full); font-size:14px;
  display:inline-flex; align-items:center; gap:6px; transition:.15s;
}
.btn-primary { background:var(--grad-brand); color:#fff; box-shadow:var(--sh-card); }
.btn-primary:hover { transform:translateY(-1px); box-shadow:var(--sh-hover); }
.btn-ghost { background:var(--card); border:1px solid var(--brand-100); color:var(--brand-700); }
.btn-ghost:hover { background:var(--brand-050); }
.btn-sm { height:30px; padding:0 var(--sp-4); font-size:13px; }
.icon-btn {
  width:28px; height:28px; border-radius:50%; display:grid; place-items:center;
  color:var(--text-400); font-size:13px; background:var(--brand-050);
}
.icon-btn:hover { background:var(--brand-100); color:var(--brand-700); }

input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
  height:38px; padding:0 var(--sp-3); border-radius:var(--r-sm);
  background:var(--card); border:1px solid var(--line); outline:none; transition:.15s; color:var(--text-900);
}
textarea { height:auto; padding:var(--sp-3); line-height:1.7; resize:both; min-width:240px; max-width:100%; }
input:focus, select:focus, textarea:focus {
  border-color:var(--brand-500); box-shadow:0 0 0 3px var(--brand-100);
}
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance:none; margin:0; }
select { appearance:none; padding-right:28px;
  background-image:linear-gradient(45deg,transparent 50%,var(--text-400) 50%),linear-gradient(135deg,var(--text-400) 50%,transparent 50%);
  background-position:calc(100% - 16px) 17px, calc(100% - 11px) 17px;
  background-size:5px 5px,5px 5px; background-repeat:no-repeat; }

.tag { display:inline-flex; align-items:center; height:20px; padding:0 10px; border-radius:var(--r-full); font-size:12px; white-space:nowrap; }
.tag-green { background:var(--brand-100); color:var(--brand-700); }
.tag-blue { background:var(--blue-100); color:var(--blue-600); }
.tag-gray { background:#EEF3F4; color:var(--text-600); }
[data-theme="dark"] .tag-gray { background:#223338; }
.tag-warn { background:#FBEFD9; color:#9A6A17; }

.chips { display:flex; flex-wrap:wrap; gap:var(--sp-2); }

/* 表格 */
table.grid { width:100%; border-collapse:collapse; }
table.grid th {
  font-size:12px; font-weight:400; color:var(--text-400); text-align:left;
  padding:0 0 var(--sp-2); border-bottom:1px solid var(--line);
}
table.grid td { height:44px; border-bottom:1px solid var(--line); font-size:14px; padding-right:var(--sp-3); }
table.grid tr:last-child td { border-bottom:none; }
table.grid td.right, table.grid th.right { text-align:right; }
/* 身体数据表格行可点击修改 */
.grid tr.row-edit { cursor:pointer; }
.grid tr.row-edit:hover td { background:rgba(24,167,147,.08); }

.empty { text-align:center; color:var(--text-400); font-size:13px; padding:var(--sp-6) 0; }

/* 统计块 */
.stats { display:grid; gap:var(--sp-3); }
.stats.c2 { grid-template-columns:repeat(2,minmax(0,1fr)); }
.stats.c3 { grid-template-columns:repeat(3,minmax(0,1fr)); }
.stats.c4 { grid-template-columns:repeat(4,minmax(0,1fr)); }
.stat .k, .stat .v { overflow-wrap:anywhere; } /* 长文本可断行，不撑破网格 */
.stat {
  background:var(--card-alt); border-radius:var(--r-md); padding:var(--sp-4); text-align:center;
}
.stat .k { font-size:12px; color:var(--text-400); margin-bottom:4px; }
.stat .v { font-size:18px; font-weight:700; }
.stat .v.big { font-size:26px; }

/* 编辑模式显隐 */
/* 卡片级编辑：仅 .card.editing 内的编辑控件可见 */
.edit-only { display:none !important; }
.card.editing .edit-only { display:inline-flex !important; }
.card.editing .edit-only.block { display:block !important; }
.readonly-only { display:inline-flex; }
.card.editing .readonly-only { display:none !important; }
/* 卡片右上角编辑开关 */
.card-edit-btn.on { background:var(--grad-chip); color:#fff; }

/* 行高亮 */
@keyframes flashRow { 0%,100%{background:transparent} 30%,70%{background:var(--brand-050)} }
.flash { animation:flashRow 1s ease-in-out 2; border-radius:var(--r-sm); }

/* ---------------- 助手栏 ---------------- */
.assistant {
  flex:0 0 auto; padding:var(--sp-3) var(--sp-8) var(--sp-4);
  background:linear-gradient(to top, var(--bg-app) 55%, transparent);
}
.assistant .wrap { padding-bottom:0; }
.bubbles {
  display:flex; flex-direction:column; gap:var(--sp-2);
  max-height:0; overflow-y:auto; margin-bottom:0; opacity:0;
  transition:max-height .25s ease, margin-bottom .25s ease, opacity .2s ease;
}
/* 鼠标移入「输入条」（猫头+输入框这一条）或输入框聚焦时展开；
   感应边界 = .wrap 内容条本身，离开输入条左右即收起（不再感应整行空白） */
.assistant .wrap:hover .bubbles,
.assistant:focus-within .bubbles {
  max-height:min(42vh, 340px); margin-bottom:var(--sp-2); opacity:1;
}
.bubble {
  background:var(--card); border-radius:var(--r-md); padding:var(--sp-3) var(--sp-4);
  box-shadow:var(--sh-card); font-size:13px; line-height:1.7; max-width:100%;
}
.bubble.user { background:var(--brand-050); }
.bubble .b-head { display:flex; gap:6px; align-items:center; font-weight:600; margin-bottom:4px; }
.bubble .acts { display:flex; gap:var(--sp-2); margin-top:var(--sp-3); }
.form-grid { display:grid; grid-template-columns:76px 1fr; gap:var(--sp-2) var(--sp-3); align-items:center; margin:var(--sp-2) 0; }
.form-grid label { font-size:12px; color:var(--text-400); }
.form-grid input, .form-grid select { height:32px; width:100%; }

/* 设置 · 菜单显示开关 */
.mod-toggles { display:flex; flex-wrap:wrap; gap:8px 20px; padding:2px 0 4px; }
.mod-toggle { display:flex; align-items:center; gap:7px; font-size:13px; cursor:pointer; user-select:none; }
.mod-toggle input { width:15px; height:15px; cursor:pointer; margin:0; }

.askbar {
  display:flex; align-items:center; gap:var(--sp-3); background:var(--card);
  border-radius:var(--r-xl); padding:var(--sp-3) var(--sp-4); box-shadow:var(--sh-card);
}
.askbar .cat { font-size:22px; }
.askbar input[type=text] { flex:1; height:34px; border:none; background:transparent; padding:0; min-width:0; }
.askbar input[type=text]:focus { box-shadow:none; }
/* 输入条右侧「确认」按钮：点击等同回车提交 */
.ask-send {
  flex:none; height:34px; padding:0 18px; border:0; border-radius:var(--r-full);
  background:var(--grad-brand); color:#fff; font-size:13px; font-weight:600;
  cursor:pointer; box-shadow:var(--sh-hover);
}
.ask-send:active { transform:scale(.96); }
@media (max-width:767px) { .ask-send { height:32px; padding:0 14px; } }

/* ---------------- 设置抽屉 ---------------- */
.drawer-mask { position:fixed; inset:0; background:rgba(10,40,36,.28); opacity:0; pointer-events:none; transition:.2s; z-index:50; }
.drawer-mask.open { opacity:1; pointer-events:auto; }
.drawer {
  position:fixed; top:0; right:0; bottom:0; width:440px; background:var(--card); z-index:51;
  transform:translateX(100%); transition:transform .24s ease; box-shadow:var(--sh-pop);
  display:flex; flex-direction:column;
}
.drawer.open { transform:none; }
.drawer-head { padding:var(--sp-5) var(--sp-6) var(--sp-4); border-bottom:1px solid var(--line); display:flex; align-items:center; }
.drawer-head h2 { font-size:18px; margin:0; flex:1; }
.drawer-body { flex:1; overflow-y:auto; padding:var(--sp-5) var(--sp-6); }
.drawer-foot { padding:var(--sp-4) var(--sp-6); border-top:1px solid var(--line); display:flex; gap:var(--sp-3); }
.field { margin-bottom:var(--sp-5); }
.field > label { display:block; font-size:13px; font-weight:600; margin-bottom:6px; }
.field .desc { font-size:12px; color:var(--text-400); margin-bottom:6px; line-height:1.6; }
.field input, .field select, .field textarea { width:100%; }
.group-title {
  font-size:13px; font-weight:700; color:var(--text-900);
  letter-spacing:.02em; margin:var(--sp-5) 0 var(--sp-3);
  padding:4px 0 4px 9px; border-left:3px solid var(--brand-500);
  display:flex; align-items:center;
}
.group-title:first-child { margin-top:0; }

/* 设置 · 标签页 */
.settings-tabs {
  display:flex; gap:2px; padding:var(--sp-3) var(--sp-6) 0;
  border-bottom:1px solid var(--line); flex:0 0 auto;
}
.settings-tab {
  border:none; background:none; padding:9px 16px 10px;
  font-size:13px; color:var(--text-400); cursor:pointer;
  border-radius:8px 8px 0 0; border-bottom:2px solid transparent;
  margin-bottom:-1px; transition:color .15s, background .15s;
}
.settings-tab:hover { color:inherit; background:rgba(24,167,147,.06); }
.settings-tab.active {
  color:var(--brand-500); font-weight:600;
  border-bottom-color:var(--brand-500); background:rgba(24,167,147,.08);
}
.settings-pane { display:none; }
.settings-pane.active { display:block; }

/* toast */
.toast-wrap { position:fixed; bottom:96px; left:50%; transform:translateX(-50%); z-index:60; display:flex; flex-direction:column; gap:var(--sp-2); align-items:center; }
.toast {
  background:rgba(18,48,57,.92); color:#fff; padding:10px 18px; border-radius:var(--r-full);
  font-size:13px; box-shadow:var(--sh-pop); display:flex; gap:var(--sp-3); align-items:center;
  animation:toastIn .2s ease;
}
.toast button { color:var(--brand-300); font-size:13px; font-weight:600; }
@keyframes toastIn { from{opacity:0; transform:translateY(8px)} to{opacity:1} }

/* 进度条 / 强度条 */
.bar { height:6px; border-radius:var(--r-full); background:var(--brand-050); overflow:hidden; }
.bar > i { display:block; height:100%; background:var(--grad-brand); }
.intensity { display:flex; gap:4px; }
.intensity i { width:26px; height:6px; border-radius:var(--r-full); background:var(--brand-050); }
.intensity i.on { background:var(--grad-chip); }

/* 序号圆 */
.seq {
  width:26px; height:26px; border-radius:50%; display:grid; place-items:center;
  background:var(--grad-brand); color:#fff; font-size:12px; font-weight:700; flex:0 0 auto;
}

.canvas-box { width:100%; background:var(--card-alt); border-radius:var(--r-md); padding:var(--sp-3); }
canvas { display:block; width:100%; }

.row { display:flex; align-items:center; gap:var(--sp-3); }
.row.wrap-r { flex-wrap:wrap; }
.grow { flex:1; min-width:0; }
.mt2 { margin-top:var(--sp-2); } .mt3 { margin-top:var(--sp-3); } .mt4 { margin-top:var(--sp-4); }
.mb2 { margin-bottom:var(--sp-2); } .mb3 { margin-bottom:var(--sp-3); }
.center { text-align:center; }

/* ---------- 模态框（替代 window.prompt） ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(18, 48, 57, .35);
  display: grid; place-items: center;
  animation: fadeIn .15s ease;
}
.modal {
  width: min(440px, calc(100vw - 48px));
  background: var(--card); border-radius: var(--r-lg);
  box-shadow: var(--sh-pop); padding: var(--sp-5);
  animation: modalIn .18s ease;
}
.modal-title { font-size: 15px; font-weight: 600; color: var(--text-900); margin-bottom: var(--sp-3); }
.modal-body { display: flex; flex-direction: column; gap: var(--sp-2); max-height: 55vh; overflow: auto; }
.modal-body input {
  width: 100%; height: 38px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: #fff; color: var(--text-900); font-size: 14px; outline: none;
  box-sizing: border-box;
}
.modal-body input:focus { border-color: var(--brand-500); box-shadow: 0 0 0 3px var(--brand-100); }
.modal-field { display: flex; align-items: center; gap: var(--sp-3); }
.modal-field > span { width: 76px; flex: 0 0 auto; font-size: 13px; color: var(--text-600); }
.modal-btns { display: flex; justify-content: flex-end; gap: var(--sp-2); margin-top: var(--sp-4); }
.modal-btns .btn-primary {
  height: 34px; padding: 0 18px; border: none; border-radius: var(--r-full);
  background: var(--grad-brand); color: #fff; font-size: 13px; font-weight: 600; cursor: pointer;
}
.modal-btns .btn-ghost {
  height: 34px; padding: 0 18px; border: 1px solid var(--brand-100); border-radius: var(--r-full);
  background: #fff; color: var(--brand-600); font-size: 13px; cursor: pointer;
}
@keyframes modalIn { from { transform: translateY(8px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- 回到顶部悬浮按钮 ---------- */
.back-top {
  position: fixed; right: 28px; bottom: 104px; z-index: 70;
  height: 40px; padding: 0 14px; border: none; border-radius: var(--r-full);
  background: var(--grad-brand); color: #fff; font-size: 13px; font-weight: 600;
  cursor: pointer; box-shadow: var(--sh-pop); align-items: center;
  animation: fadeIn .2s ease;
}
.back-top:hover { opacity: .9; }

/* ---------- 日期选择器 ---------- */
.date-pick {
  height: 34px; padding: 0 4px 0 12px;
  border: 1px solid var(--line); border-radius: var(--r-full);
  background: var(--card); color: var(--text-700);
  font-size: 13px; font-family: inherit; cursor: pointer;
}
.date-pick:hover { border-color: var(--brand-500); }
.date-pick::-webkit-calendar-picker-indicator { cursor: pointer; opacity: .55; }
.date-pick::-webkit-calendar-picker-indicator:hover { opacity: 1; }


/* ---------- 动作库列表 ---------- */
.lib-row { display:flex; gap:var(--sp-3); align-items:center; padding:10px 0; border-bottom:1px solid var(--line); }
.lib-row .lib-info { flex:1; min-width:0; }
/* 示意图加载失败/缺图占位 */
.ex-img-fallback { background:var(--brand-050); border:1px solid var(--line); border-radius:var(--r-lg); }


/* ---------- 菜品营养标签 ---------- */
.tag-nutri { background:#FFF3E0; color:#9A6A17; font-variant-numeric:tabular-nums; }
[data-theme="dark"] .tag-nutri { background:#3A3222; color:#E8B96A; }

/* ---------- 动作选择弹窗 ---------- */
.modal-opts { gap:6px; }
.modal-opt {
  display:flex; align-items:center; gap:8px; padding:7px 10px;
  border:1px solid var(--line); border-radius:8px; cursor:pointer;
}
.modal-opt:hover { border-color:var(--brand-500); background:var(--brand-050); }
.modal-opt input { width:15px; height:15px; flex:0 0 auto; accent-color:var(--brand-500); }
.modal-opt .opt-label { font-size:13px; font-weight:500; color:var(--text-900); white-space:nowrap; }
.modal-opt .opt-desc { margin-left:auto; padding-left:10px; font-size:12px; color:var(--text-600); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

/* ============================================================
   登录页覆盖层（需求文档 18 章）
   ============================================================ */
.login-overlay {
  position:fixed; inset:0; z-index:100; display:flex; align-items:center; justify-content:center;
  background:linear-gradient(135deg,#0B2E2A 0%,#123B4A 55%,#0B4A42 100%);
  background-size:cover; background-position:center;
  transition:opacity .3s ease;
}
.login-overlay[hidden] { display:none; }
.login-overlay.hide { opacity:0; pointer-events:none; }
.login-overlay::before {
  content:''; position:absolute; inset:0;
  background:linear-gradient(180deg,rgba(8,32,30,.42) 0%,rgba(8,32,30,.55) 100%);
}
.login-card {
  position:relative; width:min(400px,88vw); padding:var(--sp-8) var(--sp-6);
  background:rgba(10,26,30,.38);
  backdrop-filter:saturate(1.5) brightness(1.08);
  -webkit-backdrop-filter:saturate(1.5) brightness(1.08);
  border:1px solid rgba(255,255,255,.22); border-radius:var(--r-xl);
  box-shadow:0 12px 40px rgba(0,0,0,.28),
    inset 0 1px 0 rgba(255,255,255,.30), inset 0 -1px 0 rgba(255,255,255,.06);
  text-align:center;
}
.login-logo { font-size:40px; line-height:1; }
.login-card h1 { font-size:20px; margin:10px 0 2px; color:#fff; }
.login-sub { font-size:12px; color:rgba(255,255,255,.72); margin-bottom:var(--sp-5); }
.login-card input[type=text], .login-card input[type=password] {
  display:block; width:260px; margin:0 auto var(--sp-3); padding:10px 14px;
  border:1px solid rgba(255,255,255,.30); border-radius:var(--r-md); font-size:14px; outline:none;
  background:rgba(255,255,255,.12); color:#fff; transition:.15s;
}
.login-card input::placeholder { color:rgba(255,255,255,.55); }
.login-card input[type=text]:focus, .login-card input[type=password]:focus {
  border-color:var(--brand-500); background:rgba(255,255,255,.18); box-shadow:0 0 0 3px rgba(59,199,166,.28);
}
.login-err { min-height:20px; font-size:12px; color:#ff9d9d; margin:2px 0 var(--sp-2); }
.login-btn {
  display:flex; width:260px; height:40px; margin:0 auto; padding:0;
  justify-content:center; align-items:center; font-size:15px;
  border-radius:var(--r-md); border:none; cursor:pointer;
}
.login-foot { margin-top:var(--sp-4); font-size:11px; color:rgba(255,255,255,.45); }
.login-tune {
  width:260px; margin:6px auto 0; display:flex; align-items:center; gap:8px;
  font-size:11px; color:rgba(255,255,255,.65);
}
.login-tune input[type=range] {
  flex:1; height:3px; margin:0; padding:0; border:none; border-radius:2px;
  -webkit-appearance:none; appearance:none; background:rgba(255,255,255,.28); outline:none; cursor:pointer;
}
.login-tune input[type=range]:focus { outline:none; }
.login-tune input[type=range]::-webkit-slider-thumb {
  -webkit-appearance:none; appearance:none; width:13px; height:13px; border-radius:50%;
  background:#fff; border:none; box-shadow:0 1px 4px rgba(0,0,0,.35);
}
.login-tune input[type=range]::-moz-range-thumb {
  width:13px; height:13px; border-radius:50%; background:#fff; border:none;
  box-shadow:0 1px 4px rgba(0,0,0,.35);
}
.login-tune .op-val { width:34px; text-align:right; font-variant-numeric:tabular-nums; }

/* ================= 网页版新增 ================= */

/* ---- 登录页：标签切换 / 邮箱输入 / 验证码行 ---- */
.login-tabs { display:flex; gap:4px; margin:6px 0 10px; background:rgba(255,255,255,.08); border-radius:var(--r-full); padding:3px; }
.login-tab { flex:1; height:30px; border:0; background:transparent; color:rgba(255,255,255,.65); border-radius:var(--r-full); font-size:13px; cursor:pointer; }
.login-tab.active { background:var(--grad-chip); color:#fff; font-weight:600; }
.login-view { display:flex; flex-direction:column; gap:8px; align-items:center; }
.login-card input[type=email], .login-card input[type=tel] {
  width:260px; height:38px; background:rgba(255,255,255,.1); border:1px solid rgba(255,255,255,.22);
  border-radius:var(--r-sm); color:#fff; padding:0 12px; outline:none; font-size:14px;
}
.login-card input[type=email]:focus { border-color:var(--brand-300); box-shadow:0 0 0 3px rgba(24,167,147,.25); }
.login-card input[type=email]::placeholder { color:rgba(255,255,255,.55); }
.login-card .code-row { display:flex; gap:8px; align-items:center; width:260px; }
.login-card .code-row input[type=text] { flex:1; width:auto; margin-bottom:0; }

/* ---- 登录页：登录模式三段切换（CloudBase / Cloudflare / 本地账号） ---- */
.mode-seg {
  display:flex; gap:4px; margin-bottom:6px; padding:3px;
  background:rgba(255,255,255,.10); border:1px solid rgba(255,255,255,.16); border-radius:var(--r-md);
}
.mode-btn {
  flex:1 1 0; min-width:0; height:30px; border:0; background:transparent; cursor:pointer;
  color:rgba(255,255,255,.68); border-radius:calc(var(--r-md) - 2px);
  font-size:12px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; transition:.15s;
}
.mode-btn:hover { color:#fff; background:rgba(255,255,255,.08); }
.mode-btn.active { background:var(--grad-chip); color:#fff; font-weight:600; box-shadow:0 1px 6px rgba(0,0,0,.18); }
.mode-tip { min-height:26px; margin:0 0 2px; padding:0 2px; font-size:11px; line-height:1.4; color:rgba(255,255,255,.60); }
.login-body { display:flex; flex-direction:column; }
.login-body .login-view { width:100%; }
.login-hint { width:260px; margin:0 auto 4px; font-size:11px; line-height:1.5; text-align:left; color:rgba(255,255,255,.52); }
.code-btn { white-space:nowrap; }
.code-btn:disabled { opacity:.55; cursor:not-allowed; }

/* ---- 移动端快速记一笔 ---- */
.quick-add { display:none; }

/* ---- 移动端底部 Tab 导航 ---- */
.tabbar { display:none; }

/* ================= 响应式（需求文档 4.2） ================= */

/* 平板：侧栏收窄为图标栏 */
@media (max-width:1023px) {
  .sidebar { width:64px; }
  .sidebar .brand-name,
  .sidebar .nav-item span:last-child { display:none; }
  .sidebar .nav-item { justify-content:center; padding:0; }
  .sidebar .nav-item .ico { font-size:20px; }
  .main-scroll { padding:var(--sp-4) var(--sp-4) 0; }
}

/* 手机：底部 Tab + 单列布局 */
@media (max-width:767px) {
  .app { display:block; height:100dvh; }
  .sidebar { display:none; }
  .main { height:100dvh; }
  .main-scroll { padding:var(--sp-3) var(--sp-3) 0; }
  .wrap, .main-scroll .wrap { max-width:100%; }
  .mod-head h1 { font-size:19px; }
  .mod-head .m-ico { font-size:22px; }

  /* 底部 Tab 导航（sidebar 之外的移动端导航） */
  .tabbar {
    display:flex; position:fixed; left:0; right:0; bottom:0; z-index:60;
    background:var(--card); border-top:1px solid var(--line);
    padding:4px 4px calc(4px + env(safe-area-inset-bottom));
    box-shadow:0 -4px 16px rgba(14,90,82,.08);
  }
  .tabbar button {
    flex:1; display:flex; flex-direction:column; align-items:center; gap:2px;
    min-height:44px; border:0; background:transparent; cursor:pointer;
    font-size:11px; color:var(--text-600); border-radius:var(--r-md); padding:4px 0;
  }
  .tabbar button .ico { font-size:20px; line-height:1; }
  .tabbar button.active { color:var(--brand-600); font-weight:600; background:var(--brand-050); }

  /* 助手栏悬于 Tab 之上 */
  .assistant { bottom:56px; }

  /* 快速记一笔悬浮按钮 */
  .quick-add {
    display:inline-flex; align-items:center; justify-content:center;
    position:fixed; right:14px; bottom:calc(56px + 74px + env(safe-area-inset-bottom)); z-index:59;
    height:40px; padding:0 16px; border:0; border-radius:var(--r-full);
    background:var(--grad-brand); color:#fff; font-size:14px; font-weight:600;
    box-shadow:var(--sh-hover); cursor:pointer;
  }

  /* 卡片与表格 */
  .card { padding:14px; border-radius:var(--r-md); }
  .stats.c2, .stats.c3, .stats.c4 { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .grid { display:block; overflow-x:auto; -webkit-overflow-scrolling:touch; }
  .grid th, .grid td { white-space:nowrap; }

  /* 抽屉与登录卡全宽化 */
  .drawer { width:100vw; max-width:100vw; }
  .login-card { width:min(340px, calc(100vw - 32px)); }
  .login-card input[type=text], .login-card input[type=password], .login-card input[type=email] { width:100%; box-sizing:border-box; }
  .login-btn { width:100%; }
  .login-hint { width:100%; box-sizing:border-box; }
  .mode-btn { font-size:11px; padding:0 2px; }
}

/* 触控目标（移动端统一放大可点区域） */
@media (pointer:coarse) {
  .grid tr.row-edit td, .btn-sm { min-height:40px; }
}

/* ---- 移动端层级修正：抽屉/弹窗必须高于底部 Tab(z60) 与悬浮按钮 ---- */
@media (max-width:767px) {
  .drawer-mask { z-index:80; }
  .drawer { z-index:81; }
  .back-top { z-index:70; }
}

/* ---- 手机端布局补丁：内容底部留出 Tab 高度；悬浮按钮纵向错开 ---- */
@media (max-width:767px) {
  /* 关键：滚动容器底部 padding，否则最后一段内容（含输入框）被底部 Tab 永久遮挡 */
  .main-scroll { padding-bottom: calc(76px + env(safe-area-inset-bottom)) !important; }

  /* 悬浮按钮纵向排列、互不重叠：助手(56) < 记一笔(68) < 回顶部(118) */
  .quick-add { bottom: calc(68px + env(safe-area-inset-bottom)); right: 14px; }
  .back-top { bottom: calc(118px + env(safe-area-inset-bottom)); right: 14px; }

  /* 弹窗移动端优化：单手可达、触控目标 44px、输入框 16px 防 iOS 聚焦缩放 */
  .modal-overlay { align-items: end; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  .modal { width: calc(100vw - 32px); }
  .modal-body input, .modal-body textarea { font-size: 16px; }
  .modal-btns .btn-primary, .modal-btns .btn-ghost { height: 44px; padding: 0 22px; font-size: 14px; }
  .modal-opt { padding: 12px 10px; }
}

/* ---- 手机端：助手输入条被固定 Tab 栏遮挡的修复 ---- */
@media (max-width:767px) {
  /* main 列高度 = 视口 - 底部Tab(约53px) - 安全区：滚动区和助手条都收进 Tab 上方 */
  .main { height: calc(100dvh - 60px - env(safe-area-inset-bottom)); }
  /* 内容不再需要大 padding（遮挡源头已除），只留呼吸空间 */
  .main-scroll { padding-bottom: var(--sp-3) !important; }
  /* 助手输入条右侧让位给「记一笔/回顶部」悬浮按钮，避免点击冲突 */
  .assistant .wrap { margin-right: 108px; }
}

/* ---- 「记一笔」按钮：仅记账页(桌面)显示；手机端一律隐藏 ---- */
.quick-add.show { display:inline-flex; right:22px; bottom:22px; }
@media (max-width:767px) {
  .quick-add { display:none !important; }
}
/* 助手输入条在手机端不再需要给记一笔让位 */
@media (max-width:767px) {
  .assistant .wrap { margin-right: 56px; }
}
/* 补充：桌面端记一笔完整定位与样式（基础样式原只在移动端媒体查询里定义） */
.quick-add.show {
  position:fixed; z-index:58; height:40px; padding:0 18px;
  border:0; border-radius:var(--r-full); background:var(--grad-brand); color:#fff;
  font-size:14px; font-weight:600; box-shadow:var(--sh-hover); cursor:pointer;
}

/* ---- 菜名自动滚动：双段无缝循环，速率恒定 ---- */
.list.dishes li .strong-title.mq-on { display:block; }
.list.dishes li .mq-track { display:inline-flex; white-space:nowrap; will-change:transform; }
.list.dishes li .mq-seg { display:inline-block; padding-right:48px; } /* 段间距 = 两次出现之间的空隙 */
.list.dishes li .strong-title.mq-on .mq-track {
  animation: dish-mq var(--mq-dur, 10s) linear infinite;
}
@keyframes dish-mq {
  from { transform: translateX(0); }
  to   { transform: translateX(calc(0px - var(--mq-tw, 360px))); } /* 恰好一个段宽 → 循环无缝 */
}

/* ---- 健身实拍图：等比缩放进容器（保持裁剪比例），不撑破布局 ---- */
.ex-img { max-width: 100%; }

/* ---- 动作卡紧凑布局 v2（仅训练页动作卡；动作库 lib-row 不受影响） ---- */
.ex-card { padding:14px 16px; }
/* 四项关键信息：单行紧凑条，窄屏自动换行 */
.ex-facts { display:flex; flex-wrap:wrap; gap:4px 16px; font-size:13px; line-height:1.6; }
.ex-facts b { font-weight:600; color:var(--text-900); }
/* 主区 grid-areas：桌面 [要点|错误|示意图] 三列 + 打卡条横跨底部；手机 [要点|错误] + [示意图|打卡] 两行两列 */
.ex-top {
  display:grid; gap:10px 16px; margin-top:10px; align-items:start;
  grid-template-columns:minmax(0,1fr) minmax(0,1fr) 180px;
  grid-template-areas:"t1 t2 v" "log log v";
}
.ex-top .a-t1 { grid-area:t1; min-width:0; }
.ex-top .a-t2 { grid-area:t2; min-width:0; border-left:1px dashed var(--line); padding-left:16px; }
.ex-top .a-v { grid-area:v; min-width:0; }
.ex-top .a-log { grid-area:log; }
.tip-head { font-weight:600; font-size:13px; margin-bottom:4px; }
.tip-head.warn { color:var(--warn); }
.ex-top .list li { padding-left:14px; margin-bottom:3px; font-size:12.5px; line-height:1.55; }
/* 打卡横条：标题 + 各组行 + 加一组，一行放下（窄屏自动换行） */
.ex-log {
  display:flex; flex-wrap:wrap; align-items:center; gap:6px 14px;
  background:var(--card-alt); border-radius:var(--r-md); padding:8px 12px;
}
.log-title { font-weight:600; font-size:13px; white-space:nowrap; }
/* 各组行纵向堆叠、占满可用宽度：输入框 grow 拉伸，行尾「×」恒距「加一组」按钮 gap 间距，不重叠 */
.ex-log-rows { display:flex; flex-direction:column; align-items:stretch; gap:6px; flex:1; min-width:0; }
.ex-log .ex-log-row { display:flex; align-items:center; gap:6px; margin:0; }
.ex-log .ex-add { margin:0; flex:none; align-self:center; }
.ex-log .ex-log-row .dim { white-space:nowrap; }
/* 关键：width:0 + flex-basis:0 让输入框不贡献固有宽度（默认 size≈20 字符会把组行撑出容器，
   行尾「×」压到「加一组」按钮上）；纯 grow 均分剩余宽度，行永不溢出 */
.ex-log input[type=number] { width:0; flex:1 1 0; min-width:0; height:30px; }
.ex-log .ex-add { margin:0; flex:none; }
.ex-log .icon-btn { width:26px; height:26px; line-height:26px; flex:none; }
@media (max-width:767px) {
  .ex-card { padding:12px; }
  .ex-top {
    grid-template-columns:40% minmax(0,1fr); gap:10px;
    grid-template-areas:"t1 t2" "v log";
  }
  .ex-top .a-t2 { padding-left:10px; }
  .ex-visual .ex-img { width:100% !important; height:auto !important; }
  /* 打卡条在 60% 窄列内改为竖排：标题一行、每组一行、加一组右对齐 */
  .ex-log { flex-direction:column; align-items:stretch; gap:6px; padding:8px 10px; }
  .ex-log .log-title { font-size:12px; }
  .ex-log-rows { flex-direction:column; align-items:stretch; gap:6px; }
  .ex-log .ex-log-row { gap:5px; }
  .ex-log .ex-log-row .dim { font-size:11px; }
  .ex-log input[type=number] { flex:1 1 0; min-width:38px; height:30px; padding:0 5px; }
  .ex-log .icon-btn { width:22px; height:22px; line-height:22px; font-size:12px; }
  .ex-log .ex-add { height:28px; padding:0 10px; font-size:12px; align-self:flex-end; }
}
/* 极窄屏（≤359px）：组号让位，保证输入框可用宽度 */
@media (max-width:359px) {
  .ex-log .ex-log-row .dim { display:none; }
}

/* ---- 修复：录入行 input 的 flex min-width:auto 拒绝收缩，把动作卡撑出屏幕 ---- */
.row input, .row select { min-width:0; }
/* 手机端所有 flex 行允许换行：行最小宽度降为单个控件宽度，彻底消除横向撑破 */
@media (max-width:767px) {
  .row { flex-wrap:wrap; }
}

/* ---- 双端同步状态指示（position:fixed 固定视口顶部，滚动/回顶都不消失） ---- */
.sync-chip {
  position: fixed;
  top: calc(8px + env(safe-area-inset-top));
  right: 14px;
  z-index: 70; /* 高于内容与 tabbar(60)，低于抽屉(80/81)与弹窗 */
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  background: transparent; /* 始终全透明：彻底避免遮挡下方内容 */
  border: 1px solid var(--line); /* 实线边框占位 */
  pointer-events: none; /* 纯指示，不挡下方点击 */
  transition: color .2s, border-color .2s;
}
.sync-chip.synced { color: var(--brand-600); border-color: var(--brand-100); }
.sync-chip.syncing { color: var(--text-700, var(--text-900)); opacity: .85; }
.sync-chip.error { color: var(--danger); border-color: var(--danger); }
@media (max-width:767px) {
  .sync-chip { right: 10px; font-size: 11px; padding: 3px 10px; }
}

/* 设置抽屉打开时：同步胶囊抬到抽屉之上(z 85>81)，放在抽屉头部行内、✕ 左侧
   （头部行高约 60px，✕ 右缘距屏 14px、宽约 32px → 胶囊右缘退到 70px 外，永不相叠） */
body.drawer-open .sync-chip {
  top: calc(16px + env(safe-area-inset-top));
  right: 70px;
  z-index: 85;
}
