:root {
  --bg: #f4f5f2; --card: #fff; --line: #e3e6df; --text: #1f2a1f; --muted: #6b7568;
  --accent: #2f7d4f; --accent-soft: #e5f2e9; --good: #2f7d4f; --bad: #c0442f;
  --radius: 12px; --shadow: 0 1px 3px rgba(0, 0, 0, .06);
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
       color: var(--text); background: var(--bg); }
button { font: inherit; color: inherit; cursor: pointer; }
h1 { font-size: 18px; margin: 0; white-space: nowrap; }
h2 { font-size: 15px; margin: 0; }
h3 { font-size: 14px; margin: 18px 0 6px; }

.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
/* 三阶段设置面板：顶栏下方下拉，浮在页面上，不占位置；层级低于用户 / 详情弹窗（z-index 10、12） */
.settings-panel { position: fixed; top: 52px; left: 16px; right: 16px; z-index: 8; display: flex; flex-direction: column; gap: 6px;
                  padding: 8px; background: var(--bg, #f4f5f2); border: 1px solid var(--line); border-radius: calc(var(--radius) + 4px);
                  box-shadow: 0 12px 32px rgba(0, 0, 0, .18); }
.settings-panel[hidden] { display: none; }
/* 设置面板的遮罩：顶栏以下的页面，浅色半透明；点它收起面板 */
.settings-mask { position: fixed; top: 56px; left: 0; right: 0; bottom: 0; z-index: 7; background: rgba(0, 0, 0, .2); }
.settings-mask[hidden] { display: none; }
/* 设置汇总：结果上方一行 */
.summary { flex: none; display: flex; align-items: baseline; gap: 4px; font-size: 13px; color: var(--text, #1f2a1f); padding: 2px 4px;
           white-space: nowrap; overflow: hidden; cursor: pointer; }
.summary > span { flex: none; }
.summary > .cons { flex: 0 1 auto; min-width: 120px; overflow: hidden; text-overflow: ellipsis; }   /* 约束：最少 120px，放不下时省略 */
.summary .st { font-weight: 700; color: #dd6b20; margin-left: 14px; }
.summary .st:first-child { margin-left: 0; }
.summary:hover { color: var(--accent); }
.topbar { display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: var(--card);
          border-bottom: 1px solid var(--line); }

.layout { display: flex; flex-direction: column; gap: 6px; padding: 8px 16px 16px; height: calc(100vh - 50px); }
.section-title { flex: none; font-size: 14px; color: var(--muted); margin: 6px 2px 0; }   /* 区域标题在灰色背景上 */
.box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
       padding: 14px 16px; min-height: 0; overflow: auto; }
.box-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.empty, .loading, .error { color: var(--muted); padding: 24px 8px; text-align: center; grid-column: 1 / -1; }
.error { color: var(--bad); }

/* 用户栏：一行；左侧"添加"固定，用户多了横向滚动 */
/* 召回区：顶部横条（为谁召回 + 约束），下面是用户栏 */
.recall-box { flex: none; padding: 0; overflow: hidden; }
.recall-box .box-head { display: block; margin: 0; padding: 10px 14px; background: #fff; border-bottom: 1px solid var(--line);
                        font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.users-bar { flex: none; display: flex; gap: 8px; padding: 8px 10px; overflow: hidden; }
/* 设置区：Rank by Seq-v2（分数融合 + 窗口）、Rerank（多样性），右侧 Recommend */
.settings-box.lam { flex: none; background: var(--card); border-radius: var(--radius); padding: 10px 16px; gap: 22px; overflow: visible; flex-wrap: wrap; }
.set-group { display: flex; align-items: center; gap: 6px; }
/* 三个阶段统一的标签：橙底白字（与绿色主按钮区分） */
.stage-tag { display: inline-block; font-size: 12px; font-weight: 700; color: #fff; background: #dd6b20; border-radius: 6px;
             padding: 3px 10px; margin-right: 10px; white-space: nowrap; vertical-align: middle; box-shadow: 0 1px 2px rgba(0, 0, 0, .15); }
.set-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.user-list { flex: 1; min-width: 0; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: thin; padding-bottom: 2px; }
.user-list .user-tile { flex: 0 0 132px; }
#add-user { flex: 0 0 52px; }
.user-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 5px 4px; border: 1px solid var(--line);
             border-radius: 10px; background: #fafbf9; text-align: center; min-width: 0; }
.user-tile:hover { border-color: var(--accent); }
.user-tile { position: relative; }
.user-tile .edit { position: absolute; top: 2px; right: 2px; width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center;
                   font-size: 11px; line-height: 1; color: var(--muted); opacity: .55; }
.user-tile:hover .edit, .user-tile.active .edit { opacity: 1; }
.user-tile .edit:hover { background: var(--accent); color: #fff; }   /* ✎ 编辑：打开用户弹窗 */
.user-tile.active { border-color: var(--accent); background: var(--accent-soft); }
.user-tile .l0, .user-tile .l1, .user-tile .l2 { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-tile .l0 { font-size: 12px; font-weight: 700; color: var(--text); padding: 0 16px; box-sizing: border-box; }   /* 两侧留出 ✎ 的位置 */
.user-tile .l1 { font-size: 11px; color: var(--text); }
.user-tile .l2:empty::before { content: "\00a0"; }   /* 没有第二行时也占一行高度，方块等高 */
.user-tile .l2 { font-size: 11px; color: var(--muted); }
.user-tile.add { border-style: dashed; border-color: var(--accent); }
.user-tile .plus { font-size: 20px; line-height: 1; color: var(--accent); }
.link-btn { border: 0; background: none; color: var(--accent); font-size: 12px; }

/* 用户弹窗内容 */
.field { margin-bottom: 12px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; }
.field small { font-weight: 400; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 3px 12px; }
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn { border: 1px solid var(--accent); background: var(--accent); color: #fff; border-radius: 8px; padding: 6px 16px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--accent); }
.btn.big { padding: 9px 28px; font-size: 15px; font-weight: 600; }


.history { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; }
.hist { flex: 0 0 88px; border: 1px solid var(--line); border-radius: 8px; padding: 0; background: #fff; overflow: hidden; text-align: left; }
.hist img { width: 100%; height: 60px; object-fit: cover; display: block; }
.hist .noimg { width: 100%; height: 60px; display: grid; place-items: center; }   /* No image 水平垂直居中 */
.hist { position: relative; }
.hist .del { position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center;
             background: rgba(0, 0, 0, .55); color: #fff; font-size: 13px; line-height: 1; padding: 0; }
.hist .del:hover { background: var(--bad); }
.hist-empty { color: var(--muted); font-size: 13px; padding: 14px 4px; }
.hist span:not(.del) { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 11px; padding: 2px 4px;
  line-height: 1.35; height: calc(2 * 1.35em + 4px); box-sizing: border-box; }   /* 标题固定两行高度 */

/* 推荐区：占满页面宽度 */
/* 结果区：头部（分布图、分数、分页）固定，只有下面的推荐卡片滚动 */
.recs-box { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.recs-box .rec-head { flex: none; }
.recs-box #recs { flex: 1; min-height: 0; overflow-y: auto; align-content: start; grid-auto-rows: max-content; padding: 2px 4px 4px; margin: 0 -4px; }
/* 推荐区头部：上层信息与按钮，下层一排 5 张分布图 */
.rec-head { display: flex; align-items: center; gap: 24px; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }   /* 与推荐卡片之间的分割线 */
.rec-side { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; flex: none; }   /* 右侧：信息在上、翻页按钮在下 */
/* 推荐信息：一行、左对齐，放不下时省略 */
.rec-meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; color: var(--text, #1f2a1f); }
/* 调节效果区：分布图 + 两个分数，下面一条分割线与推荐结果隔开 */
.effects { display: flex; align-items: center; gap: 24px; min-width: 0; }
.effects[hidden] { display: none; }
.stats { display: flex; gap: 10px; flex: none; }
.stat { background: #f3f5f1; border: 1px solid var(--line); border-radius: 8px; padding: 6px 14px; min-width: 96px; text-align: center; }
.stat .v { font-size: 20px; font-weight: 700; line-height: 1.2; }
.stat .k { font-size: 11px; color: var(--muted); }
.charts { min-width: 0; display: flex; gap: 20px; flex-wrap: wrap; }
.dchart { display: flex; flex-direction: column; }
.dchart .dt { font-size: 12px; font-weight: 600; color: var(--c, var(--muted)); line-height: 1.2; }
.dchart .dnone { width: 240px; height: 58px; display: grid; place-items: center; font-size: 11px; color: var(--muted);
                 border-bottom: 1px solid var(--line); }
.dchart svg { display: block; overflow: visible; }
.dchart .axis { stroke: var(--line); stroke-width: 1; }
.dchart .grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 3; }   /* 50% / 100% 参考线 */
.dchart .area { fill: var(--c); opacity: .14; }
.dchart .line { fill: none; stroke: var(--c); stroke-width: 1.6; }
.dchart .hit { fill: transparent; }
.dchart .hit:hover { fill: var(--c); fill-opacity: .35; }
.dchart text { font-size: 9px; fill: var(--muted); text-anchor: middle; }
.pager .btn, .lam .link-btn { white-space: nowrap; }
.pager { display: flex; gap: 8px; flex: none; justify-content: flex-end; }
.lam { display: flex; align-items: center; gap: 6px; font-size: 13px; background: #fafbf9; border: 1px solid var(--line);
       border-radius: 8px; padding: 4px 10px; }
.lam label { font-weight: 600; white-space: nowrap; }
.lam input { width: 64px; accent-color: var(--accent); }
.lam output { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 34px; }
.lam .lbl { font-weight: 600; white-space: nowrap; }
.lam select { font: inherit; font-size: 12px; padding: 2px 6px; min-width: 76px; border: 1px solid var(--line); border-radius: 6px; background: #fff; margin-right: 6px; }
/* 分数融合分段条：三段宽度 = 三个权重；两个手柄在段与段的分界处 */
.fuse { position: relative; width: 320px; height: 26px; cursor: pointer; user-select: none; touch-action: none; margin: 0 6px; }
.fuse .track { display: flex; width: 100%; height: 100%; border-radius: 6px; overflow: hidden; }   /* 轨道裁切圆角，宽度为 0 的段不露出 */
.fuse .seg { flex: none; min-width: 0; padding: 0; height: 100%; display: flex; align-items: center; justify-content: center; overflow: hidden;
             white-space: nowrap; font-size: 11px; font-weight: 600; color: #fff; }
.fuse .seg.fs-model { background: #2f5f8a; }
.fuse .seg.fs-health { background: #2f7d4f; }
.fuse .seg.fs-novelty { background: #7b5ea7; }   /* 紫色：与橙色阶段标签区分 */
.fuse .knob { position: absolute; top: -3px; width: 10px; height: 32px; margin-left: -5px; border-radius: 4px; background: #fff;
              border: 1px solid #8a9488; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); cursor: ew-resize; }
.fuse .knob:focus-visible { outline: 2px solid var(--accent); }
.rerank { color: var(--muted); font-size: 12px; }
.card .foot { align-self: stretch; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }   /* 卡片底行：名次变化 + 热度 */
.pop { color: var(--muted); font-size: 12px; white-space: nowrap; margin-left: auto; }
.rerank b.up { color: var(--good); }
.rerank b.down { color: var(--bad); }
.health-text { color: hsl(var(--h) 75% 30%); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.card { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 0 0 10px;
        border: 1px solid var(--line); border-radius: var(--radius); background: #fff; overflow: hidden; text-align: left; }
.card:hover { box-shadow: 0 4px 14px rgba(0, 0, 0, .08); }
.card .ph { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: #eef0ec; }
.card > *:not(.ph):not(.ph-wrap):not(.badges):not(.like) { margin: 0 10px; }
/* 卡片右上角：♡ 加入历史，♥ 已在历史（再点删除） */
.card .like { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
              background: rgba(255, 255, 255, .9); color: #c0442f; font-size: 17px; line-height: 1; margin: 0;
              box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.card .like:hover { transform: scale(1.08); }
.card .like.on { background: #c0442f; color: #fff; }
.hint { font-size: 12px; color: #a8561c; margin-right: 4px; align-self: center; white-space: nowrap; }
.badges { position: absolute; top: 8px; left: 8px; right: 44px; display: flex; gap: 6px; align-items: center; }   /* 图片左上角：名次 + 餐型 */
.meal-tag { background: var(--c); color: #fff; border-radius: 6px; padding: 1px 8px; font-size: 12px; font-weight: 600;
            box-shadow: 0 1px 3px rgba(0, 0, 0, .25); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ph-wrap { position: relative; display: block; width: 100%; }
.ph-wrap .health { position: absolute; left: 8px; bottom: 8px; display: block; max-width: calc(100% - 16px);
                   white-space: nowrap; overflow: hidden; text-overflow: ellipsis; box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }   /* 图片左下角，最多一行 */
.ph-wrap .health em { margin-left: 4px; }
.rank { flex: none; background: rgba(0, 0, 0, .6); color: #fff; border-radius: 6px; padding: 0 7px;
        font-size: 12px; font-weight: 600; }
.cname { font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
         line-height: 1.3; min-height: 2.6em; }   /* 始终占两行高度，卡片内容对齐 */

.cmeta { color: var(--muted); font-size: 12px; }
.cmeta .meal { color: var(--text); font-weight: 600; }   /* 餐型（由类别归并，重排的校准 / 多样性按它调整） */
.noimg { display: grid; place-items: center; color: var(--muted); font-size: 12px; background: #eef0ec; }

.health { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; border-radius: 6px; padding: 1px 8px; }
.health em { font-style: normal; font-weight: 400; font-size: 11px; opacity: .8; border-left: 1px solid currentColor; padding-left: 4px; }
.health { color: hsl(var(--h) 75% 27%); background: hsl(var(--h) 70% 91%); }   /* --h：健康分的色相（app.js healthHue） */

.skeleton .ph, .skeleton .l1, .skeleton .l2 { background: linear-gradient(90deg, #eef0ec, #f7f8f5, #eef0ec); background-size: 200% 100%;
  animation: shimmer 1.2s infinite; border-radius: 6px; }
.skeleton .l1 { height: 14px; width: 80%; }
.skeleton .l2 { height: 12px; width: 50%; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* 详情弹窗 */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: grid; place-items: center; z-index: 10; padding: 16px; }
.modal[hidden] { display: none; }
.modal-card { position: relative; background: #fff; border-radius: var(--radius); width: min(760px, 100%); max-height: 90vh;
              display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 12px 40px rgba(0, 0, 0, .25); }
.modal-card.wide { width: min(880px, 100%); }
#modal { z-index: 12; }                                          /* 详情弹窗可叠在用户弹窗上 */
/* 底部按钮栏固定 */
.modal-foot { flex: none; display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding: 12px 24px;
              border-top: 1px solid var(--line); background: #fff; }
/* 标题栏固定在顶部，只有下面的内容滚动 */
.modal-head { flex: none; display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px 12px 24px;
              border-bottom: 1px solid var(--line); background: #fff; }
.modal-heading { flex: 1; min-width: 0; }
.modal-head h2 { font-size: 18px; margin: 0 0 2px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-close { flex: none; width: 34px; height: 34px; border-radius: 50%; border: 0; background: transparent; color: var(--muted);
               font-size: 24px; line-height: 1; cursor: pointer; display: grid; place-items: center; }
.modal-close:hover { background: #eef0ec; color: var(--text); }
.modal-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.modal-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 18px 24px 24px; }
body.modal-open { overflow: hidden; }
@media (max-width: 640px) {
  .modal { padding: 0; }
  .modal-card { width: 100%; height: 100%; max-height: none; border-radius: 0; }
  .modal-head, .modal-body, .modal-foot { padding-left: 16px; padding-right: 16px; }
  .cols { grid-template-columns: 1fr; }
}
.hero { width: 100%; max-height: 320px; object-fit: cover; border-radius: 10px; display: block; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.tag { font-size: 12px; border-radius: 6px; padding: 1px 8px; }
.tag.warn { background: #fdf0e6; color: #a8561c; }
.tag.ok { background: var(--accent-soft); color: var(--accent); }
.desc { color: #3d473b; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.cols ul { margin: 0; padding-left: 18px; }
.note { color: var(--muted); font-size: 12px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
td { padding: 3px 6px; border-bottom: 1px solid var(--line); }
td:last-child { text-align: right; }
ol { padding-left: 20px; }
ol li { margin-bottom: 6px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #333; color: #fff; padding: 8px 16px;
         border-radius: 8px; z-index: 20; }
