/* ==========================================================
   调酒师手册 · 双主题设计系统
   夜间：暗冷色（深蓝黑 + 冰蓝）   日间：高级灰（暖灰 + 石板蓝）
   ========================================================== */

:root,
:root[data-theme="dark"] {
  --bg: #0b0f14;
  --bg-elev: #11161d;
  --bg-input: #151c25;
  --border: #212a36;
  --border-strong: #2e3947;
  --accent: #5eb0ef;
  --accent-weak: rgba(94, 176, 239, 0.12);
  --text: #e6edf3;
  --text-dim: #8b98a9;
  --text-faint: #5c6a7d;
  --danger: #e5697a;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  --card-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  --card-shadow-hover: 0 20px 46px rgba(0, 0, 0, 0.48), 0 6px 16px -4px var(--accent-weak);
  --glow-a: rgba(94, 176, 239, 0.07);
  --glow-b: rgba(132, 116, 216, 0.06);
  --glass-tint: rgba(10, 14, 20, 0.44);
  --glass-border: rgba(255, 255, 255, 0.09);
}

:root[data-theme="light"] {
  --bg: #eceae7;
  --bg-elev: #f6f5f3;
  --bg-input: #ffffff;
  --border: #dcd9d4;
  --border-strong: #c6c2bb;
  --accent: #46708f;
  --accent-weak: rgba(70, 112, 143, 0.11);
  --text: #26282b;
  --text-dim: #63666b;
  --text-faint: #97999e;
  --danger: #c04a5c;
  --shadow: 0 14px 36px rgba(60, 58, 54, 0.16);
  --card-shadow: 0 4px 16px rgba(60, 58, 54, 0.14);
  --card-shadow-hover: 0 20px 42px rgba(60, 58, 54, 0.2), 0 6px 16px -4px var(--accent-weak);
  --glow-a: rgba(70, 112, 143, 0.07);
  --glow-b: rgba(120, 110, 100, 0.06);
  --glass-tint: rgba(22, 26, 32, 0.38);   /* 图片上的玻璃仍用深色调，保证文字可读 */
  --glass-border: rgba(255, 255, 255, 0.14);
}

/* 暖色调：把强调色从蓝换成橙，叠加在明/暗之上（仅覆盖强调色与环境光晕，背景/文字不变） */
:root[data-warm] {
  --accent: #ef8f43;
  --accent-weak: rgba(239, 143, 67, 0.14);
  --glow-a: rgba(239, 143, 67, 0.08);
  --glow-b: rgba(214, 138, 92, 0.06);
}
:root[data-warm][data-theme="light"] {
  --accent: #bd6323;                       /* 浅底上用更深的橙，保证可读 */
  --accent-weak: rgba(189, 99, 35, 0.12);
  --glow-a: rgba(189, 99, 35, 0.07);
  --glow-b: rgba(176, 118, 78, 0.06);
}
/* 暖·夜：主背景也换成暖调暗色（棕黑系），不再是冷蓝黑 */
:root[data-warm][data-theme="dark"] {
  --bg: #13100b;
  --bg-elev: #1b1610;
  --bg-input: #221c13;
  --border: #342b20;
  --border-strong: #473b2d;
  --text: #f1ece4;
  --text-dim: #a89a89;
  --text-faint: #7a6d5b;
  --glass-tint: rgba(18, 14, 9, 0.46);
}

:root {
  --radius: 16px;
  --radius-sm: 10px;
  --gap: 18px;
  --font-display: Georgia, "Times New Roman", "Songti SC", STSong, SimSun, serif;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
}

/* 按钮/卡片/chip 都已经有自己的 :active 反馈，去掉移动端默认的灰色点按闪烁遮罩 */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "HarmonyOS Sans SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.35s ease, color 0.35s ease;
}
/* 环境光：极淡的冷色光晕，为毛玻璃提供层次 */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(640px 420px at 85% -8%, var(--glow-a), transparent 70%),
    radial-gradient(520px 380px at -6% 36%, var(--glow-b), transparent 70%);
  transition: background 0.35s ease;
}
a { color: var(--accent); text-decoration: none; }
a:hover { opacity: 0.85; }
.hidden { display: none !important; }
/* 切页轻微淡入上浮，取代原来生硬的瞬间切换 */
main.container > section:not(.hidden) { animation: view-in 0.2s ease; }
@keyframes view-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
::selection { background: var(--accent-weak); }

::-webkit-scrollbar { width: 10px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

/* ============ 顶栏 ============ */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg);   /* 老 Safari 不支持 color-mix 时的回退，避免顶栏变透明 */
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border-bottom: 1px solid var(--border);
  transition: background-color 0.35s ease, border-color 0.35s ease;
}
.topbar-inner {
  max-width: 1100px; margin: 0 auto;
  padding: 13px clamp(16px, 4vw, 24px);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
/* logo 可以收缩省略；操作区固定不缩水——保证退出登录后变宽的「登录/注册」按钮
   永远不会把自己或旁边的按钮顶出视口，被挤压的只会是 logo 文字 */
.logo {
  flex: 1 1 auto; min-width: 0;
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-display);
  font-size: 18px; font-weight: 700; letter-spacing: 1px;
  color: var(--text);
}
.logo:hover { opacity: 1; color: var(--accent); }
/* 酒杯图标：白底透明的位图当遮罩用，填色跟着 currentColor 走，四套主题 + hover 变色都不用切图 */
.logo-mark {
  flex: 0 0 auto; width: 20px; height: 20px;
  background-color: currentColor;
  -webkit-mask-image: url('/logo-mark.png'); mask-image: url('/logo-mark.png');
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: center; mask-position: center;
  -webkit-mask-size: contain; mask-size: contain;
}
.logo-text {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.logo-en { color: var(--text-faint); font-weight: 400; font-size: 12px; letter-spacing: 1.2px; }
.topbar-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 9px; }

.container {
  max-width: 1100px; margin: 0 auto;
  padding: clamp(20px, 4vw, 32px) clamp(14px, 4vw, 24px) 90px;
}
/* 阅读型视图收窄居中，列表保持全宽多列 */
#view-detail, #view-edit, #view-profile, #view-story-edit, #view-settings, #view-import, #view-my-ingredients, #view-admin, #view-review, #view-tags, #view-menu-edit, #view-ai-chat {
  max-width: 840px; margin: 0 auto;
}

.import-example summary { color: var(--accent); cursor: pointer; font-size: 13.5px; }
.import-example pre {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 16px; margin-top: 10px;
  font-size: 12.5px; line-height: 1.7; overflow-x: auto;
}
.import-mode {
  display: flex; align-items: flex-start; gap: 8px;
  margin: 12px 0 4px; font-size: 13px; color: var(--text-dim);
  cursor: pointer; line-height: 1.5;
}
.import-mode input { margin-top: 2px; flex: 0 0 auto; accent-color: var(--accent); }

/* ============ 按钮与输入 ============ */
.btn {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: transparent; color: var(--text);
  padding: 9px 18px; font-size: 14px; font-family: inherit;
  cursor: pointer; white-space: nowrap;
  transition: border-color 0.15s, background 0.15s, color 0.15s, transform 0.1s ease;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn:disabled:hover { border-color: var(--border-strong); color: var(--text); }
.btn:disabled:active { transform: none; }
.btn-primary {
  background: var(--accent); border-color: var(--accent);
  color: var(--bg); font-weight: 600;
}
.btn-primary:hover { opacity: 0.88; color: var(--bg); }
.btn-danger { color: var(--danger); border-color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn-danger:hover { border-color: var(--danger); color: var(--danger); background: transparent; background: color-mix(in srgb, var(--danger) 8%, transparent); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-icon {
  width: 36px; height: 36px; padding: 0;
  border-radius: 50%; font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center;
}
/* 顶栏「显示设置」下拉：主题 / 基酒百科 / 酒单模式 三个开关收进同一个向下展开的菜单，
   顶栏只留一个触发按钮，给退出登录后变宽的「登录/注册」按钮腾出稳定空间 */
.view-dd { position: relative; }
.view-dd-panel {
  position: absolute; top: calc(100% + 8px); left: 0;
  min-width: 172px; max-width: calc(100vw - 32px);
  background: var(--bg-elev); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
  padding: 6px; z-index: 50;
  display: flex; flex-direction: column; gap: 2px;
  transition: background-color 0.35s ease, border-color 0.35s ease;
  animation: dd-in 0.15s ease;
  transform-origin: top left;
}
@keyframes dd-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.view-dd-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; border: none; background: transparent;
  padding: 9px 10px; border-radius: 8px;
  font-size: 13.5px; font-family: inherit; color: var(--text);
  cursor: pointer; text-align: left; white-space: nowrap;
  transition: background-color 0.15s;
}
.view-dd-item:hover { background: var(--accent-weak); }
/* 主题项在暖色套时、酒单模式项开启时，同样染成强调色提示当前状态 */
.view-dd-item.warm, .view-dd-item.active { color: var(--accent); background: var(--accent-weak); font-weight: 600; }
.view-dd-ic { font-size: 16px; width: 20px; text-align: center; flex: 0 0 auto; }

.input, textarea.input, select.input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 11px 14px; font-size: 15px; font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.35s ease;
}
.input::placeholder { color: var(--text-faint); }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
textarea.input {
  resize: none; overflow-y: hidden;
  min-height: 96px; max-height: 600px; line-height: 1.7;
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.35s ease, height 0.12s ease;
}
select.input { appearance: none; -webkit-appearance: none; cursor: pointer; }

/* ============ 搜索与分类 ============ */
.search-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.search-row .input { flex: 1 1 260px; max-width: 440px; }
.sort-group { display: flex; gap: 8px; }

.chips {
  display: flex; gap: 8px; margin-bottom: 26px;
  overflow-x: auto; padding-bottom: 4px;
  scrollbar-width: none;
  /* 右边缘渐隐提示：手机上横向筛选 chip 常常溢出容器，加一层淡出遮罩暗示"还能往右划" */
  mask-image: linear-gradient(to right, black calc(100% - 28px), transparent);
  -webkit-mask-image: linear-gradient(to right, black calc(100% - 28px), transparent);
}
.chips::-webkit-scrollbar { display: none; }

/* 分类 / 口味 双行筛选 */
.filter-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.filter-row .chips { flex: 1; min-width: 0; margin-bottom: 0; }  /* min-width:0 让 chips 能收缩并横向滚动，避免撑破整页 */
.filter-row:last-of-type { margin-bottom: 22px; }
.filter-label {
  flex: 0 0 auto;
  color: var(--text-faint); font-size: 12.5px; font-weight: 600;
  letter-spacing: 1px;
}
.chip {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 16px; font-size: 13px; font-family: inherit;
  cursor: pointer; color: var(--text-dim);
  background: transparent;
  transition: all 0.15s;
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip:active { transform: scale(0.96); }
.chip.active {
  background: var(--accent-weak); color: var(--accent);
  border-color: var(--accent); font-weight: 600;
}
.chip .count { opacity: 0.6; margin-left: 5px; font-size: 12px; }

/* ============ 按材料找酒 ============ */
.match-toggle.active {
  background: var(--accent-weak); color: var(--accent);
  border-color: var(--accent); font-weight: 600;
}
.match-panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 20px;
  transition: background-color 0.35s ease, border-color 0.35s ease;
}
.match-head {
  color: var(--text-dim); font-size: 13px; margin-bottom: 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.match-head > span { flex: 1 1 240px; min-width: 0; }
.match-head-act { display: flex; gap: 8px; flex-wrap: wrap; flex: 0 0 auto; }
.ing-groups { max-height: 320px; overflow-y: auto; margin-bottom: 12px; }
.ing-group { margin-bottom: 12px; }
.ing-group-label {
  color: var(--text-faint); font-size: 12px; font-weight: 600;
  letter-spacing: 1px; margin-bottom: 7px;
}
.match-chips { flex-wrap: wrap; overflow: visible; margin-bottom: 0; padding-bottom: 0; }
.match-add { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.match-add .input { flex: 0 1 260px; padding: 8px 12px; min-height: 0; font-size: 14px; }
.mying-count { color: var(--text-faint); font-size: 12.5px; margin-left: auto; }

.mying-list { margin-bottom: 14px; }
.mying-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 4px; border-bottom: 1px solid var(--border);
}
.mying-row:last-child { border-bottom: none; }
.mying-name { flex: 1 1 140px; min-width: 0; font-size: 14px; }
.mying-num {
  flex: 0 0 88px; padding: 6px 10px; min-height: 0; font-size: 13px;
}
.mying-unit { flex: 0 0 84px; color: var(--text-faint); font-size: 12px; text-align: right; }
.mying-del {
  flex: 0 0 auto; background: none; border: none; color: var(--text-faint);
  font-size: 20px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.mying-del:hover { color: var(--danger, #e5484d); }
.mying-add { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.mying-add .input { flex: 1 1 160px; padding: 8px 12px; min-height: 0; font-size: 14px; }
.mying-add .mying-num { flex: 0 1 110px; }
.match-info { color: var(--text-dim); font-size: 13.5px; margin-top: 12px; }
.match-info b { color: var(--accent); }

.card-ready { box-shadow: 0 0 0 1.5px var(--accent), var(--card-shadow); }
.match-badge {
  display: inline-block;
  font-size: 11.5px; padding: 2px 9px;
  border-radius: 6px; margin-top: 8px;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.match-badge.ok {
  background: var(--accent-weak); color: #bfe0f7;
  border: 1px solid var(--accent);
}
.match-badge.lack {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(242, 245, 248, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

/* ============ 今天喝点啥 ============ */
.lucky-box { max-width: 420px; padding: 0; overflow: hidden; }
.lucky-cover { position: relative; aspect-ratio: 16 / 9; }
.lucky-cover img {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover;
}
.lucky-body { padding: 22px 26px 26px; }
.lucky-label {
  color: var(--accent); font-size: 12px; font-weight: 600;
  letter-spacing: 2px; margin-bottom: 6px;
}
.lucky-body h2 {
  font-family: var(--font-display);
  font-size: 26px; letter-spacing: 1px; line-height: 1.3;
}
.lucky-en { color: var(--text-faint); font-size: 13px; letter-spacing: 1px; margin-top: 2px; }
.lucky-meta { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 4px; }
.lucky-meta span {
  background: var(--accent-weak); color: var(--accent);
  border-radius: 6px; padding: 2px 10px; font-size: 12px;
}
.lucky-desc { color: var(--text-dim); font-size: 13.5px; line-height: 1.8; margin-top: 10px; }
.lucky-actions { display: flex; gap: 10px; margin-top: 20px; }
.lucky-actions .btn { flex: 1; }

/* ============ 相关推荐 ============ */
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.related-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden; cursor: pointer;
  transition: border-color 0.2s ease, transform 0.35s var(--ease-out), box-shadow 0.35s var(--ease-out);
}
.related-card:hover { border-color: var(--accent); transform: translateY(-3px); box-shadow: var(--card-shadow); }
.related-card img {
  display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover;
  transition: transform 0.5s var(--ease-out);
}
.related-card:hover img { transform: scale(1.06); }
.related-card .rname { font-weight: 600; font-size: 13.5px; padding: 9px 11px 0; }
.related-card .rsub { color: var(--text-faint); font-size: 11.5px; padding: 2px 11px 10px; }

/* ============ 瀑布流 · 毛玻璃图片卡片（桌面三列 / 手机两列） ============
   用 flex 列 + JS 分配实现瀑布流；不用 CSS columns——
   iOS Safari 在多列布局中会丢失列顶元素的绘制 */
.grid { display: flex; gap: var(--gap); align-items: flex-start; }
.grid-col {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  gap: var(--gap);
}
.card {
  --rx: 0deg; --ry: 0deg; --mx: 50%; --my: 50%;
  position: relative;
  display: block;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  background: var(--bg-elev);
  box-shadow: var(--card-shadow);
  -webkit-mask-image: -webkit-radial-gradient(white, black);  /* Safari 圆角裁切 */
  transform: perspective(1000px) rotateX(var(--rx)) rotateY(var(--ry)) translateZ(0);
  transition: transform 0.5s var(--ease-out), box-shadow 0.5s var(--ease-out);
  animation: card-in 0.5s ease backwards;
}
.card:hover {
  transform: perspective(1000px) rotateX(var(--rx)) rotateY(var(--ry)) translateY(-6px) translateZ(0);
  box-shadow: var(--card-shadow-hover);
}
/* 鼠标停留时由 JS 持续写入 --rx/--ry，改用短过渡实现跟手的倾斜视差；离开时移除该类，交回上面的慢过渡回弹 */
.card.card-tilt { transition: transform 0.08s linear, box-shadow 0.4s ease; }
/* 点按时叠加轻微按下缩放，和按钮/chip 的按压手感保持一致；触屏的 --rx/--ry 由
   pointerdown 写入，这里仍要带上 rotateX/rotateY，不然按下瞬间倾斜会被压扁成纯缩放 */
.card:active {
  transform: perspective(1000px) rotateX(var(--rx)) rotateY(var(--ry)) scale(0.98) translateZ(0);
  transition-duration: 0.12s;
}
/* 卡片表面高光：跟随指针位置的柔光，配合倾斜强化"实体卡片"的光泽质感 */
.card::after {
  content: "";
  position: absolute; inset: 0;
  z-index: 1;
  background: radial-gradient(280px circle at var(--mx) var(--my), rgba(255, 255, 255, 0.16), transparent 62%);
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
}
.card.card-tilt::after { opacity: 1; }
@keyframes card-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
/* 卡片高度随图片真实比例自适应，图片完整显示不裁切；--iscale 只在 hover 时放大，
   放大留出的余量让 --imx/--imy（指针视差位移）不会露出裁切边界外的背景色 */
.card-img {
  --iscale: 1; --imx: 0px; --imy: 0px;
  display: block;
  width: 100%; height: auto;
  min-height: 120px;                  /* 图片加载前的占位，避免瀑布流跳动 */
  transform: scale(var(--iscale)) translate3d(var(--imx), var(--imy), 0);
  transition: transform 0.6s var(--ease-out);
}
.card:hover .card-img { --iscale: 1.045; }
.card-glass {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 14px 16px 15px;
  background: var(--glass-tint);
  backdrop-filter: blur(18px) saturate(1.5);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
  border-top: 1px solid var(--glass-border);
  color: #f2f5f8;                     /* 玻璃层上固定浅色文字，双主题通用 */
}
.card-glass h3 {
  font-family: var(--font-display);
  font-size: 16.5px; font-weight: 700; letter-spacing: 0.5px;
  line-height: 1.35;
}
.card-glass .en {
  color: rgba(242, 245, 248, 0.62);
  font-size: 12px; letter-spacing: 0.8px;
  margin: 1px 0 7px;
}
.card-glass .meta { color: rgba(242, 245, 248, 0.78); font-size: 12.5px; }
.card-glass .tag {
  display: inline-block;
  background: rgba(255, 255, 255, 0.13);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  padding: 1px 8px; font-size: 11.5px;
  color: rgba(242, 245, 248, 0.85);
  margin-top: 9px;
}
.card-glass .stats {
  display: flex; gap: 12px; align-items: center;
  margin-top: 9px;
  color: rgba(242, 245, 248, 0.72); font-size: 12px;
}
.card-glass .stats span { display: inline-flex; align-items: center; gap: 4px; }
.card-glass .stats .cat {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.13);
  border-radius: 6px; padding: 1px 8px;
  font-size: 11px;
}

/* 横版到方形的图片卡片：信息栏下移到图片下方，不遮挡画面（fitCard 自动判定） */
.card-stack .card-img { min-height: 0; }
.card-stack .card-glass {
  position: static;
  background: var(--bg-elev);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-top: 1px solid var(--border);
  color: var(--text);
  transition: background-color 0.35s ease, border-color 0.35s ease;
}
.card-stack .card-glass .en { color: var(--text-faint); }
.card-stack .card-glass .meta { color: var(--text-dim); }
.card-stack .card-glass .stats { color: var(--text-dim); }
.card-stack .card-glass .stats .cat {
  background: var(--accent-weak); color: var(--accent);
  border: none;
}
.card-stack .match-badge.lack {
  background: var(--bg-input); color: var(--text-dim);
  border-color: var(--border);
}
.ic { width: 12px; height: 12px; fill: currentColor; flex: 0 0 auto; }

.empty { text-align: center; color: var(--text-dim); padding: 70px 0; font-size: 15px; }
.pager {
  display: flex; justify-content: center; align-items: center;
  gap: 7px; margin-top: 30px;
}
.pager-top { margin: 0 0 20px; }
.pager-top:empty { display: none; }

.page-btn, .page-num {
  min-width: 34px; height: 34px; padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-elev);
  color: var(--text-dim);
  font-size: 13.5px; font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s, transform 0.15s;
}
.page-btn:hover:not(:disabled), .page-num:hover {
  border-color: var(--accent); color: var(--accent);
  transform: translateY(-1px);
}
.page-btn:disabled { opacity: 0.3; cursor: default; }
.page-btn svg { width: 15px; height: 15px; }
span.page-num.active {
  background: var(--accent); border-color: var(--accent);
  color: var(--bg); font-weight: 700;
  font-family: var(--font-display);
  cursor: default; transform: none;
  box-shadow: 0 4px 14px var(--accent-weak);
}
.page-ellipsis { color: var(--text-faint); padding: 0 3px; letter-spacing: 2px; user-select: none; }

/* ============ 详情页 ============ */
/* 容器本身是一个定高的 flex 列（高度由 app.js sizeDetailPager 按视口算好）：
   悬浮操作条 auto 高度，翻页容器吃掉剩余空间。操作条收起时靠 max-height 过渡真正把空间让给翻页容器，
   不是简单挪到视口外——这样往下翻页时收起来才能多看到一屏内容，而不是留一块空白 */
#view-detail:not(.hidden) { display: flex; flex-direction: column; }

/* 悬浮操作条：常驻在 5 页翻页容器之上，点赞/收藏/编辑/删除不再占专门的一页；
   往下翻页时自动收起腾地方，往上翻页/回到顶部时弹回来（见 app.js handlePagerScroll） */
.detail-float-actions {
  flex: 0 0 auto; z-index: 3;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 4px 14px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  max-height: 120px; overflow: hidden;
  transition: max-height 0.28s var(--ease-out), opacity 0.2s ease, padding 0.28s var(--ease-out);
}
.detail-float-actions.bar-collapsed {
  max-height: 0; padding-top: 0; padding-bottom: 0; opacity: 0; pointer-events: none;
}

/* 5 页整屏翻页容器：内部 scroll-snap 承担"阻尼感"，右侧留白给点串导航；
   flex:1 吃掉操作条之外的剩余高度，操作条收起/展开时会跟着自动伸缩，不需要 JS 重算 */
.detail-pager {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  margin-right: 40px;
}
.detail-page {
  scroll-snap-align: start;
  scroll-snap-stop: always;
  min-height: 100%;
  padding: 4px 2px 40px;
  box-sizing: border-box;
}

/* 右侧点串：常驻圆点，当前页对应的点展开显示文字标签 */
.detail-dots {
  position: fixed; right: clamp(8px, 2.6vw, 26px); top: 50%; transform: translateY(-50%);
  z-index: 4; display: flex; flex-direction: column; gap: 14px;
}
.detail-dot { display: flex; align-items: center; gap: 8px; cursor: pointer; justify-content: flex-end; }
.dot-mark {
  width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto;
  background: var(--border-strong);
  transition: background-color 0.3s var(--ease-out), transform 0.3s var(--ease-out);
}
.dot-label {
  font-size: 12px; letter-spacing: 1px; color: var(--text-dim);
  max-width: 0; overflow: hidden; white-space: nowrap; opacity: 0;
  transition: max-width 0.35s var(--ease-out), opacity 0.25s ease;
}
.detail-dot.active .dot-mark { background: var(--accent); transform: scale(1.4); }
.detail-dot.active .dot-label,
.detail-dot:hover .dot-label { max-width: 90px; opacity: 1; color: var(--accent); font-weight: 600; }

/* 风味画像：不再是带边框的卡片，直接大幅浮在头图上——左右居中，纵向位置由 JS 按图片横竖版比例算好
   （见 app.js drawTasteRadar），legibility 靠画布自身画的深色光晕 + 描边文字，而不是一个方框。
   可点击收起/重新展开（toggleTasteRadar），所以这里允许接收点击，光标给出可点提示 */
.hero-radar {
  position: absolute; left: 50%; z-index: 2;
  transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  cursor: pointer;
}
.hero-radar-label {
  font-size: 12px; letter-spacing: 3px; color: rgba(242, 245, 248, 0.82);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  opacity: 1; transition: opacity 0.28s ease, transform 0.28s ease;
}
.hero-radar.collapsed .hero-radar-label { opacity: 0; transform: translateY(-6px); }
.hero-radar canvas { display: block; }

.detail-hero {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--card-shadow);
  margin-bottom: 22px;
}
/* 照片框体：高度跟随图片原始长宽比，完整显示不裁切 */
.detail-hero.hero-photo-frame { aspect-ratio: auto; }
.hero-img {
  position: absolute; left: 0; top: -9%;
  width: 100%; height: 118%;
  object-fit: cover;
  will-change: transform;
}
.hero-img.hero-anchored {
  position: static; display: block;
  width: 100%; height: auto;
  will-change: auto;
  transform: none !important;
}
.hero-glass {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 18px 24px 20px;
  background: var(--glass-tint);
  backdrop-filter: blur(18px) saturate(1.5);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
  border-top: 1px solid var(--glass-border);
  color: #f2f5f8;
}
.hero-glass h1 {
  font-family: var(--font-display);
  font-size: clamp(22px, 4.5vw, 30px);
  font-weight: 700; letter-spacing: 1px; line-height: 1.3;
}
.hero-glass .en {
  color: rgba(242, 245, 248, 0.65);
  font-size: 14px; letter-spacing: 1.5px; margin-top: 2px;
}

.spec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px; margin: 22px 0;
}
.spec {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 15px;
  transition: background-color 0.35s ease, border-color 0.35s ease;
}
.spec .label { color: var(--text-faint); font-size: 12px; margin-bottom: 3px; letter-spacing: 0.5px; }
.spec .value { font-size: 14px; }
.spec-link { color: var(--accent); text-decoration: none; }
.spec-link:hover { text-decoration: underline; }
/* 基酒详情页的产地/风味/建议是长段落，改单列铺满，而不是挤在窄格子里；左侧描边+图标呼应 iba-card 的编辑体系 */
.spec-grid-wide { grid-template-columns: 1fr; gap: 12px; }
.spec-grid-wide .spec {
  padding: 14px 16px 15px 18px;
  border-left: 3px solid var(--accent);
  border-top-left-radius: 4px; border-bottom-left-radius: 4px;
}
.spec-grid-wide .spec .label { font-size: 12.5px; letter-spacing: 1px; color: var(--accent); font-weight: 600; }
.spec-grid-wide .spec .value { line-height: 1.8; margin-top: 2px; }

/* 基酒百科：列表页顶部的编辑式引导语换成更像"栏目页首"的介绍条 */
.spirit-intro {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--accent-weak), transparent 70%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 26px;
  margin-bottom: 24px;
}
.spirit-intro h1 {
  font-family: var(--font-display); font-size: clamp(21px, 3.4vw, 27px);
  letter-spacing: 1px; margin-bottom: 6px;
}
.spirit-intro p { color: var(--text-dim); font-size: 13.5px; max-width: 640px; line-height: 1.7; }
.spirit-intro-deco {
  position: absolute; right: -10px; bottom: -22px;
  font-size: 92px; line-height: 1; opacity: 0.08;
  pointer-events: none; user-select: none;
}

/* 基酒分级角标：六大基酒 / 特色 & 餐酒基酒（复用 .ctag 胶囊样式，独立配色不与新手/网红/IBA 混淆） */
.ctag-spirit-base { background: var(--accent); }
.ctag-spirit-specialty { background: rgba(154, 140, 196, 0.92); }

/* 基酒百科：品牌/版本卡片（详情页内的小节，图左文右） */
.brand-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin: 4px 0 28px; }
.brand-card {
  display: flex; gap: 12px;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px;
  transition: background-color 0.35s ease, border-color 0.2s ease, transform 0.35s var(--ease-out), box-shadow 0.35s var(--ease-out);
}
.brand-card:hover { border-color: var(--accent); transform: translateY(-3px); box-shadow: var(--card-shadow); }
.brand-img { flex: 0 0 64px; width: 64px; height: 64px; border-radius: var(--radius-sm); object-fit: cover; }
.brand-img-empty {
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; background: var(--accent-weak); opacity: 0.85;
}
.brand-body { min-width: 0; flex: 1; }
.brand-name { font-weight: 700; font-size: 14px; }
.brand-name .en { color: var(--text-faint); font-weight: 400; font-size: 12px; margin-left: 6px; }
.brand-meta { color: var(--accent); font-size: 11.5px; margin-top: 3px; letter-spacing: 0.3px; }
.brand-desc { color: var(--text-dim); font-size: 12.5px; line-height: 1.6; margin: 6px 0 0; }
.brand-actions { display: flex; gap: 6px; margin-top: 10px; }

/* 空态：与主页 .empty 一致的留白节奏，加一个弱化大图标呼应故事卡片的装饰手法 */
.spirit-empty-icon { font-size: 34px; opacity: 0.35; margin-bottom: 10px; }

/* 主页快捷筛选按钮：新手推荐 / 网红新品 */
.special-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* 酒单模式：隐藏工作向按钮，仅保留搜索/网红/架构/口味 */
body.menu-mode #sort-group,
body.menu-mode .match-toggle,
body.menu-mode .lucky-btn,
body.menu-mode #beginner-btn,
body.menu-mode #match-panel,
body.menu-mode .topbar-actions .btn-primary { display: none !important; }
.menu-banner {
  background: var(--accent-weak); border: 1px solid var(--accent);
  border-radius: var(--radius-sm); padding: 9px 14px; margin: 0 0 16px;
  font-size: 13px; color: var(--text);
}
.menu-banner a { color: var(--accent); margin-left: 8px; white-space: nowrap; }

/* 我的酒单卡片（个人主页） */
.menus-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.menu-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 24px; }
.menu-card {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 16px;
}
.menu-card-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-card-sub { color: var(--text-dim); font-size: 12.5px; margin: 2px 0 10px; }
.menu-card-act { display: flex; gap: 6px; flex-wrap: wrap; }

/* 选酒器 */
.menu-filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 12px 0; }
.menu-filters .input { flex: 1 1 180px; max-width: 260px; }
.menu-filters .chips { margin-bottom: 0; flex: 1 1 100%; }
.menu-edit-hint { color: var(--text-dim); font-size: 12.5px; margin-bottom: 8px; }
.menu-edit-hint a { color: var(--accent); }
.menu-row-meta { color: var(--text-faint); font-size: 12px; flex: 0 0 auto; }
.menu-save-bar { align-items: center; gap: 14px; position: sticky; bottom: 0;
  background: var(--bg); padding: 12px 0; border-top: 1px solid var(--border); }
.menu-sel-count { color: var(--text-dim); font-size: 13px; margin-right: auto; }

/* 卡片角标 & 详情标记 */
.card-tags { position: absolute; top: 10px; left: 10px; display: flex; flex-direction: column; gap: 6px; z-index: 2; pointer-events: none; }
.detail-uploader { color: var(--text-faint); font-size: 12.5px; margin: -8px 0 10px; }
.detail-uploader a { color: var(--text-dim); font-weight: 600; }
.detail-flags { display: flex; gap: 8px; flex-wrap: wrap; margin: -6px 0 16px; }
.ctag {
  display: inline-flex; align-items: center; font-size: 12px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px; color: #fff; white-space: nowrap;
  backdrop-filter: blur(4px); box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.ctag-beginner { background: rgba(52, 168, 110, 0.92); }
.ctag-trending { background: rgba(224, 82, 82, 0.92); }
.ctag-iba { background: rgba(158, 122, 42, 0.94); letter-spacing: 0.3px; }
.ctag-home { background: rgba(214, 129, 39, 0.92); }

/* IBA 官方标准配方卡片（详情页，与本站配方并列展示） */
.iba-card {
  background: var(--bg-elev);
  border: 1px solid rgba(158, 122, 42, 0.45);
  border-left: 3px solid rgba(158, 122, 42, 0.9);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin: 26px 0;
  transition: background-color 0.35s ease, border-color 0.35s ease;
}
.iba-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.iba-logo {
  flex: 0 0 auto; font-weight: 800; font-size: 13px; letter-spacing: 1px; color: #fff;
  background: rgba(158, 122, 42, 0.94); border-radius: 8px; padding: 7px 10px;
}
.iba-title { font-weight: 700; font-size: 15px; }
.iba-sub { color: var(--text-dim); font-size: 12px; margin-top: 2px; }
.iba-ings { margin-bottom: 12px; }
.iba-row { display: flex; gap: 10px; margin: 8px 0; font-size: 14px; }
.iba-row .iba-k { flex: 0 0 auto; color: var(--text-faint); font-size: 12px; padding-top: 2px; letter-spacing: 0.5px; }
.iba-row p { margin: 0; line-height: 1.7; }
.iba-en { margin-top: 10px; }
.iba-en summary { cursor: pointer; color: var(--text-dim); font-size: 12.5px; }
.iba-en p { color: var(--text-dim); font-size: 13px; line-height: 1.6; margin: 8px 0 0; }

/* 用户上传配方：详情页「大家的配方」区块 + 上传/编辑页 */
.urecipe-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.urecipe-bar .section-title { margin-bottom: 0; }

/* 详情页「配方」区块下的预估成本（基于「我的材料」个人报价） */
.cost-row { margin: 10px 0 20px; padding-top: 10px; border-top: 1px dashed var(--border); }
.cost-amt { font-weight: 700; color: var(--accent); }
.cost-hint { color: var(--text-faint); font-size: 13px; }
.cost-missing { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.cost-missing .chip { padding: 4px 12px; font-size: 12.5px; }
.urecipe-tip { color: var(--text-dim); font-size: 12.5px; margin: 6px 0 14px; line-height: 1.6; }
.urecipe-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 0 0 14px;
  transition: background-color 0.35s ease, border-color 0.35s ease;
}
.urecipe-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.urecipe-name { font-weight: 700; font-size: 15px; }
.urecipe-ops { flex: 0 0 auto; font-size: 12.5px; display: flex; gap: 12px; }
.urecipe-ops a { color: var(--text-dim); }
.urecipe-ops a.del:hover { color: #e05252; }
.urecipe-meta { color: var(--text-dim); font-size: 12px; margin: 4px 0 12px; display: flex; gap: 14px; flex-wrap: wrap; }
.urecipe-source { color: var(--text); }
.urecipe-ings { margin-bottom: 10px; }
.urecipe-specs { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; margin: 2px 0 10px; }
.urecipe-specs em { font-style: normal; color: var(--text-faint); font-size: 12px; margin-right: 6px; }
.urecipe-steps { margin-top: 4px; }
.urecipe-note { color: var(--text-dim); font-size: 13px; line-height: 1.7; margin: 8px 0 0; }
.urecipe-block {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 16px;
}
.urecipe-block-head { display: flex; align-items: center; justify-content: space-between; }
.urecipe-block-no { font-weight: 700; font-size: 14px; color: var(--text-dim); letter-spacing: 0.5px; }
.urecipe-block-del { width: auto; padding: 0 10px; font-size: 12.5px; }

/* 编辑页：配方文本粘贴识别 */
.recipe-paste {
  background: var(--bg-elev); border: 1px dashed var(--border);
  border-radius: var(--radius-sm); padding: 14px 16px 12px;
}
.recipe-paste textarea { min-height: 96px; resize: none; overflow-y: hidden; margin-top: 4px; }
.paste-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.paste-actions .form-hint { margin: 0; }

/* 编辑页特别标记勾选 */
.flag-row { display: flex; gap: 22px; flex-wrap: wrap; }
.flag-check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; font-size: 14px; }
.flag-check input { width: 16px; height: 16px; accent-color: var(--accent); }

/* 编辑页：口味画像六轴滑杆 */
.taste-score-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 24px; }
.taste-score-row { display: flex; align-items: center; gap: 10px; }
.taste-score-label { flex: 0 0 40px; font-size: 13px; color: var(--text-dim); }
.taste-score-slider { flex: 1; accent-color: var(--accent); }
.taste-score-val { flex: 0 0 20px; text-align: right; font-size: 13px; color: var(--text-faint); }

/* 详情页口味标签 */
.taste-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: -6px 0 18px; }
.taste-label { color: var(--text-faint); font-size: 12px; letter-spacing: 0.5px; }
.taste-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.taste-tag {
  font-size: 13px; padding: 4px 12px; border-radius: 999px;
  background: var(--bg-elev); border: 1px solid var(--border); color: var(--text);
}

/* 酒的故事卡片 */
.story-card {
  position: relative;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 28px 24px 30px;
  margin: 26px 0;
  overflow: hidden;
  transition: background-color 0.35s ease, border-color 0.35s ease;
}
.story-card::before {
  content: "\201C";
  position: absolute; left: 14px; top: -18px;
  font-family: var(--font-display);
  font-size: 110px; line-height: 1;
  color: var(--accent); opacity: 0.14;
  pointer-events: none;
}
.story-card::after {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--accent); opacity: 0.55;
}
.story-label {
  color: var(--accent); font-size: 12px; font-weight: 600;
  letter-spacing: 3px; margin-bottom: 10px;
}
.story-card p {
  font-family: var(--font-display);
  font-size: 15.5px; line-height: 2;
  color: var(--text); letter-spacing: 0.3px;
  white-space: pre-wrap;   /* 保留粘贴/输入内容中的换行与段落 */
}
.story-card.story-empty p { color: var(--text-dim); font-family: inherit; font-size: 14px; }
.story-foot {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 12px; margin-top: 14px; font-size: 12.5px;
}
.story-author { color: var(--text-dim); font-family: var(--font-display); letter-spacing: 0.5px; }

/* 故事编辑独立页面 */
.story-target { margin: 4px 0 10px; }
.story-target-name {
  font-family: var(--font-display);
  font-size: 20px; font-weight: 700; letter-spacing: 0.5px;
}
.story-target-en { color: var(--text-faint); font-size: 13px; margin-left: 10px; letter-spacing: 0.8px; }
.story-edit-tip { color: var(--text-dim); font-size: 13px; margin-bottom: 14px; }
textarea.story-textarea {
  min-height: 320px;
  font-family: var(--font-display);
  font-size: 15.5px; line-height: 2; letter-spacing: 0.3px;
}

.section-title {
  color: var(--accent); font-size: 13px; font-weight: 600;
  letter-spacing: 2px; text-transform: uppercase;
  margin: 30px 0 12px;
}
.ingredient-list, .step-list { list-style: none; }
.ingredient-list li {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 9px 2px; font-size: 15px;
  border-bottom: 1px dashed var(--border);
}
.ingredient-list .amount { color: var(--accent); font-size: 14px; white-space: nowrap; margin-left: 16px; }
.step-list { counter-reset: step; }
.step-list li {
  counter-increment: step;
  position: relative;
  padding: 7px 0 7px 34px;
  font-size: 15px; line-height: 1.7;
}
.step-list li::before {
  content: counter(step);
  position: absolute; left: 0; top: 9px;
  width: 22px; height: 22px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  color: var(--accent); font-size: 12px;
  display: flex; align-items: center; justify-content: center;
}
.desc-text { color: var(--text-dim); line-height: 1.9; font-size: 15px; white-space: pre-wrap; }

.byline {
  color: var(--text-faint); font-size: 13px;
  margin-top: 34px; padding-top: 16px;
  border-top: 1px solid var(--border);
  line-height: 1.9;
}
.rev-item {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px; margin: 8px 0;
  font-size: 13px; color: var(--text-dim);
}

/* ============ 编辑器：多选分类 & 快捷步骤 ============ */
/* 分类多达数十个：收进限高的可滚动盒子，避免撑长整个表单（手机上尤甚） */
.edit-cats {
  flex-wrap: wrap; margin-bottom: 0;
  max-height: 200px; overflow-y: auto;
  align-content: flex-start;
  padding: 10px; gap: 8px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-input);
}
/* 编辑页的框架/口味选择器：换行全显，不做单行横向滚动（选择场景要看全） */
#f-framework, #f-tastes { flex-wrap: wrap; overflow: visible; margin-bottom: 0; }

.quick-steps {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 8px; margin-top: 12px;
}
.quick-steps-label { color: var(--text-faint); font-size: 12.5px; }
.chip-mini { padding: 4px 12px; font-size: 12.5px; }
.form-hint { color: var(--text-faint); font-size: 12.5px; margin-top: 8px; }
.fw-en { color: var(--text-faint); font-size: 11.5px; }

/* ============ 点赞 ============ */
.like-btn { display: inline-flex; align-items: center; gap: 6px; }
.like-btn .ic { width: 14px; height: 14px; }
.like-btn.liked {
  color: var(--accent); border-color: var(--accent);
  background: var(--accent-weak);
}

/* ============ 评论 ============ */
.comment-editor { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 6px; flex-wrap: wrap; }
.comment-editor textarea.input { min-height: 64px; max-height: 320px; flex: 1; }
.comment-photo {
  display: block; max-width: 260px; max-height: 260px; border-radius: var(--radius-sm);
  margin-top: 8px; cursor: zoom-in; object-fit: cover;
}
.comment-img-preview-wrap { flex: 0 0 100%; }
.comment-img-preview-wrap:empty { display: none; }
.comment-img-preview { position: relative; display: inline-block; margin-top: 8px; }
.comment-img-preview img { display: block; width: 84px; height: 84px; border-radius: var(--radius-sm); object-fit: cover; }
.comment-img-preview a {
  position: absolute; top: -6px; right: -6px; width: 18px; height: 18px;
  border-radius: 50%; background: var(--danger); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 11px; line-height: 1;
}
.comment-login-tip { color: var(--text-dim); font-size: 14px; padding: 10px 0; }
.comment-item {
  display: flex; gap: 10px;
  padding: 13px 2px; border-bottom: 1px dashed var(--border);
}
.comment-main { flex: 1; min-width: 0; }
.comment-head {
  display: flex; align-items: baseline; gap: 10px;
  font-size: 12.5px; margin-bottom: 4px;
}
.comment-head .author { color: var(--accent); font-weight: 600; }
.comment-head .time { color: var(--text-faint); }
.comment-head .del { margin-left: auto; color: var(--text-faint); font-size: 12px; }
.comment-head .del:hover { color: var(--danger); }
.comment-body { font-size: 14.5px; line-height: 1.8; white-space: pre-wrap; }
.comment-empty { color: var(--text-faint); font-size: 13.5px; padding: 14px 0; }

/* 楼中楼回复 + 求助/采纳 */
.comment-item.is-reply { padding-left: 0; border-bottom: none; }
.comment-replies { margin: 2px 0 0 34px; border-left: 2px solid var(--border); padding-left: 14px; }
.comment-replies .comment-item { border-bottom: 1px dashed var(--border); }
.comment-replies .comment-item:last-child { border-bottom: none; }
.comment-item.accepted-answer { background: var(--accent-weak); border-radius: var(--radius-sm); padding-left: 10px; }
.q-tag {
  display: inline-flex; align-items: center; gap: 3px;
  background: var(--accent); color: #fff; border-radius: 6px;
  padding: 1px 7px; font-size: 11px; font-weight: 600;
}
.q-tag.solved { background: #2fa86b; }
.accepted-tag {
  display: inline-flex; align-items: center; gap: 3px;
  color: #2fa86b; font-size: 11.5px; font-weight: 600;
}
.comment-head .accept-btn { margin-left: auto; color: var(--text-faint); font-size: 12px; }
.comment-head .accept-btn:hover { color: #2fa86b; }
.comment-head .del { margin-left: 10px; }
.comment-reply-link { color: var(--text-faint); font-size: 12.5px; margin-top: 4px; display: inline-block; }
.comment-reply-link:hover { color: var(--accent); }
.comment-reply-form { display: flex; gap: 8px; align-items: flex-start; margin-top: 8px; flex-wrap: wrap; }
.comment-reply-form textarea.input { min-height: 44px; flex: 1; font-size: 13.5px; }
.comment-question-toggle {
  display: flex; align-items: center; gap: 6px;
  color: var(--text-dim); font-size: 12.5px; margin: 6px 0 10px;
}

/* 头衔 / 徽章：全站在昵称旁展示 */
.title-badge {
  display: inline-flex; align-items: center; gap: 2px;
  background: var(--accent-weak); color: var(--accent);
  border-radius: 6px; padding: 1px 7px; font-size: 11px; font-weight: 600;
  white-space: nowrap;
}
.badge-ic { font-size: 12px; cursor: default; }
.profile-name .title-badge { font-size: 12.5px; padding: 2px 9px; margin-left: 6px; vertical-align: 2px; }
.profile-badges { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.contrib-next { color: var(--text-faint); font-size: 12px; margin-top: 4px; }

/* ============ 说书人（AI 调酒助手） ============ */
.ai-chat-intro {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--accent-weak), transparent 70%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 22px;
  margin-bottom: 14px;
}
.ai-chat-intro h1 {
  font-family: var(--font-display); font-size: clamp(21px, 3.4vw, 27px);
  letter-spacing: 1px; margin-bottom: 6px;
}
.ai-chat-intro p { color: var(--text-dim); font-size: 13.5px; max-width: 640px; line-height: 1.7; }
.ai-chat-intro-deco {
  position: absolute; right: -10px; bottom: -22px;
  font-size: 92px; line-height: 1; opacity: 0.08;
  pointer-events: none; user-select: none;
}
.ai-chat-list {
  display: flex; flex-direction: column; gap: 16px;
  min-height: 40vh;
  padding: 6px 4px 14px;
}
.ai-chat-empty { text-align: center; padding: 30px 10px; }
.ai-chat-empty p { color: var(--text-faint); font-size: 13.5px; margin: 0 0 14px; }
.ai-chat-suggests { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.ai-msg {
  display: flex; align-items: flex-end; gap: 8px;
  animation: msg-in 0.3s ease backwards;
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.ai-msg-user { flex-direction: row-reverse; }
.ai-avatar { background: linear-gradient(135deg, var(--accent), var(--accent-weak)); font-size: 15px; }
.ai-msg-bubble {
  max-width: 76%; padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: 14.5px; line-height: 1.7; white-space: normal;
}
.ai-msg-user .ai-msg-bubble { background: var(--accent-weak); color: var(--text); }
.ai-msg-ai .ai-msg-bubble { background: var(--bg-elev); border: 1px solid var(--border); color: var(--text); }
.ai-typing { color: var(--text-faint); font-style: italic; }
/* 输入框吸底：整页仍是唯一滚动区域（不锁页面高度，避免移动端浏览器 100vh/工具栏收放的各种坑），
   靠 position:sticky 让输入框始终停在视口底部，不需要再滚一层才能找到它 */
.ai-chat-form {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; gap: 10px; align-items: flex-end;
  background: var(--bg); background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  padding: 12px 0 calc(10px + env(safe-area-inset-bottom));
  margin: 0 -4px;
  padding-left: 4px; padding-right: 4px;
}
.ai-chat-form textarea.input {
  flex: 1; min-height: 44px; max-height: 140px; resize: none; overflow-y: hidden;
  border-radius: 22px; padding: 11px 18px;
}
.btn-send {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%;
  border: none; background: var(--accent); color: var(--bg);
  font-size: 17px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: opacity 0.15s, transform 0.15s;
}
.btn-send:hover { opacity: 0.88; }
.btn-send:disabled { opacity: 0.4; cursor: default; }

/* ============ 个人主页 ============ */
.profile-head {
  display: flex; align-items: center; gap: 20px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 28px;
  transition: background-color 0.35s ease, border-color 0.35s ease;
}
.avatar {
  width: 64px; height: 64px; flex: 0 0 auto;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 26px; font-weight: 700; color: #f2f5f8;
  vertical-align: middle; overflow: hidden;
}
img.avatar-img { object-fit: cover; border: 1px solid var(--border); }
.avatar-md { width: 52px; height: 52px; font-size: 21px; }
.avatar-sm { width: 26px; height: 26px; font-size: 12px; }
.avatar-c { width: 32px; height: 32px; font-size: 14px; margin-top: 2px; }

.user-chip { display: inline-flex; align-items: center; }
.user-chip:hover { opacity: 1; }
.user-chip:hover .avatar { box-shadow: 0 0 0 2px var(--accent-weak), 0 0 0 1px var(--accent); }

.profile-head-info { min-width: 0; }
.profile-bio { color: var(--text-dim); font-size: 13.5px; margin-top: 8px; line-height: 1.7; }

.avatar-edit-row {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 12px;
}
.avatar-edit-main { flex: 1; }
.upload-row { display: flex; gap: 8px; align-items: center; }
.upload-row .input { flex: 1; }
.profile-settings .field label { margin-top: 4px; }
.profile-name {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 700; letter-spacing: 0.5px;
}
.profile-sub { color: var(--text-dim); font-size: 13px; margin-top: 3px; }
.role-badge {
  display: inline-block; margin-left: 8px;
  background: var(--accent-weak); color: var(--accent);
  border-radius: 6px; padding: 1px 8px;
  font-size: 11.5px; vertical-align: 2px;
}
.role-badge.role-admin { background: var(--accent); color: #fff; }

/* 用户权限管理 */
.admin-user-list { margin-top: 6px; }
.admin-user {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 2px; border-bottom: 1px dashed var(--border);
}
.admin-user-info { flex: 1 1 auto; min-width: 0; }
.admin-user-name { font-weight: 600; }
.admin-user-sub {
  color: var(--text-dim); font-size: 12.5px; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.admin-user-act { flex: 0 0 auto; }
.admin-self { color: var(--text-faint); font-size: 12.5px; }
.stats-grid {
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 10px; margin: 18px 0 26px;
}
.stat-tile {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 8px; text-align: center;
  transition: background-color 0.35s ease, border-color 0.35s ease;
}
.stat-tile .num {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 700; color: var(--accent);
}
.stat-tile .lbl { color: var(--text-dim); font-size: 12px; margin-top: 2px; }

/* 贡献卡片 + GitHub 式活跃图 */
.donate-card {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 16px 18px; margin: 0 0 26px;
}
.donate-head { font-size: 14px; color: var(--text-dim); margin-bottom: 12px; }
.donate-body { display: flex; align-items: center; gap: 16px; }
.donate-qr { flex: 0 0 auto; width: 96px; height: 96px; border-radius: var(--radius-sm); overflow: hidden; }
.donate-qr img { width: 100%; height: 100%; object-fit: cover; }
.donate-qr-placeholder {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  text-align: center; font-size: 12px; line-height: 1.5; color: var(--text-faint);
  background: var(--bg-input); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm);
}
.donate-text { flex: 1 1 auto; font-size: 13px; line-height: 1.6; color: var(--text-dim); }
@media (max-width: 480px) { .donate-body { flex-direction: column; align-items: flex-start; } }
.donate-owner-tools { margin-top: 12px; }

.contrib-card {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 16px 18px; margin: 0 0 26px;
}
.contrib-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.contrib-title { font-size: 14px; color: var(--text-dim); }
.contrib-num { font-family: var(--font-display); font-size: 22px; font-weight: 700; color: var(--accent); }
.contrib-pending { color: var(--text-faint); font-size: 12.5px; }
.hm-legend { display: flex; align-items: center; gap: 3px; color: var(--text-faint); font-size: 11.5px; }
.heatmap-wrap { overflow-x: auto; padding-bottom: 4px; }
.hm-months { display: flex; gap: 3px; margin-bottom: 3px; height: 11px; }
.hm-mon { width: 11px; flex: 0 0 auto; font-size: 9px; color: var(--text-faint); white-space: nowrap; overflow: visible; }
.heatmap { display: flex; gap: 3px; }
.hm-col { display: flex; flex-direction: column; gap: 3px; flex: 0 0 auto; }
.hm-cell {
  width: 11px; height: 11px; border-radius: 2px; flex: 0 0 auto;
  /* rgba 回退给不支持 color-mix 的老 Safari（色相固定但层级仍可辨） */
  display: inline-block; background: rgba(128, 128, 128, 0.14); background: color-mix(in srgb, var(--text) 8%, transparent);
}
.hm-empty { background: transparent; }
.hm-l0 { background: rgba(128, 128, 128, 0.14); background: color-mix(in srgb, var(--text) 8%, transparent); }
.hm-l1 { background: rgba(94, 176, 239, 0.32); background: color-mix(in srgb, var(--accent) 32%, transparent); }
.hm-l2 { background: rgba(94, 176, 239, 0.55); background: color-mix(in srgb, var(--accent) 55%, transparent); }
.hm-l3 { background: rgba(94, 176, 239, 0.78); background: color-mix(in srgb, var(--accent) 78%, transparent); }
.hm-l4 { background: var(--accent); }

.checkin-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.checkin-streak { color: var(--text-dim); font-size: 12.5px; }
.leaderboard-link { margin: 0 0 26px; }

/* 排行榜 */
.leaderboard-list { margin-top: 8px; }
.leaderboard-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 6px;
  border-bottom: 1px dashed var(--border); cursor: pointer;
}
.leaderboard-row:hover { background: var(--bg-elev); }
.leaderboard-row.me { background: color-mix(in srgb, var(--accent) 10%, transparent); border-radius: var(--radius-sm); }
.lb-rank {
  flex: 0 0 28px; text-align: center; font-weight: 700; color: var(--text-faint); font-size: 13px;
}
.lb-rank.top { font-size: 18px; }
.lb-info { flex: 1 1 auto; min-width: 0; }
.lb-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-pts { flex: 0 0 auto; font-family: var(--font-display); font-weight: 700; color: var(--accent); }

/* 标签管理 */
.tag-toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.tag-toolbar .input { flex: 1 1 200px; max-width: 300px; }
.tag-toolbar .chips { margin-bottom: 0; }
.tag-bulk {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 14px; margin-bottom: 12px;
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--text-dim);
}
.tag-row { display: flex; align-items: center; gap: 12px; padding: 9px 2px; border-bottom: 1px dashed var(--border); }
.tag-check { width: 16px; height: 16px; accent-color: var(--accent); flex: 0 0 auto; }
.tag-name {
  flex: 1 1 auto; min-width: 0; font-weight: 600; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tag-name:hover { color: var(--accent); }
.tag-name .en { color: var(--text-faint); font-weight: 400; font-size: 12px; margin-left: 8px; }
.tag-toggles { display: flex; gap: 6px; flex: 0 0 auto; }

/* 贡献审核列表 */
.review-item { display: flex; align-items: center; gap: 12px; padding: 12px 2px; border-bottom: 1px dashed var(--border); }
.review-info { flex: 1 1 auto; min-width: 0; }
.review-name { font-weight: 600; }
.review-pts { color: var(--accent); font-size: 12.5px; font-weight: 600; margin-left: 6px; }
.review-sub { color: var(--text-dim); font-size: 12.5px; margin-top: 2px; }
.review-sub a { color: var(--accent); }
.review-act { display: flex; gap: 8px; flex: 0 0 auto; }

.tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.mini-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 2px;
  border-bottom: 1px dashed var(--border);
  cursor: pointer;
}
.mini-item:hover .mini-name { color: var(--accent); }
.mini-name { font-weight: 600; }
.mini-name .en { color: var(--text-faint); font-weight: 400; font-size: 12.5px; margin-left: 8px; }
.mini-sub { color: var(--text-dim); font-size: 12.5px; margin-top: 1px; }
.mini-side {
  display: flex; gap: 12px; align-items: center; flex: 0 0 auto;
  color: var(--text-dim); font-size: 12.5px;
}
.mini-side span { display: inline-flex; align-items: center; gap: 4px; }
.profile-settings { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.profile-settings .input { margin-bottom: 10px; }

/* ============ 编辑表单 ============ */
.edit-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.edit-head h1 { font-family: var(--font-display); font-size: 24px; letter-spacing: 1px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 8px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
.row-list .row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.row-list .row .input { flex: 1; }
.row-del {
  background: none; border: none;
  color: var(--text-faint); cursor: pointer;
  font-size: 15px; padding: 6px 8px;
  transition: color 0.15s;
}
.row-del:hover { color: var(--danger); }
.form-error { color: var(--danger); font-size: 13px; min-height: 20px; margin: 10px 0 0; }
.form-actions { display: flex; gap: 10px; margin-top: 18px; }

/* ============ 弹窗 ============ */
.modal {
  position: fixed; inset: 0;
  background: rgba(4, 7, 10, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 16px;
}
.modal-box {
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px 28px;
  width: 100%; max-width: 380px;
}
.modal-box h2 { font-family: var(--font-display); margin-bottom: 20px; font-size: 21px; letter-spacing: 1px; }
.modal-box .input { margin-bottom: 12px; }
.auth-switch { display: flex; justify-content: space-between; margin-top: 16px; font-size: 13px; }
.auth-switch a:last-child { color: var(--text-faint); }

/* ============ Toast ============ */
.toast {
  position: fixed;
  bottom: calc(28px + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%);
  background: var(--bg-elev);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 11px 24px;
  border-radius: 999px;
  font-size: 14px;
  box-shadow: var(--shadow);
  z-index: 200;
  max-width: calc(100vw - 40px);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ============ 平板/窄窗口适配（介于桌面 1100px 容器和 640px 手机规则之间的空当）============ */
@media (max-width: 900px) {
  .container { padding-left: clamp(12px, 3vw, 20px); padding-right: clamp(12px, 3vw, 20px); }
  .form-grid { gap: 12px; }
}

/* ============ 手机适配 ============ */
@media (max-width: 640px) {
  :root { --gap: 12px; }
  body { font-size: 14.5px; }

  /* iOS Safari 会在聚焦的输入框字号 <16px 时自动放大整页，松手也不一定缩回去；
     手机上把所有输入框统一提到 16px 从根上避免这个跳动 */
  .input, textarea.input, select.input { font-size: 16px; }

  .topbar-inner { padding: 11px 14px; }
  .logo { font-size: 16px; gap: 6px; }
  .logo-mark { width: 18px; height: 18px; }
  .logo-en { display: none; }
  .topbar-actions { gap: 7px; }
  .topbar-actions .btn { padding: 7px 12px; font-size: 13px; }
  .btn-icon { width: 34px; height: 34px; padding: 0; }

  .search-row .input { max-width: none; }

  /* 保持两列瀑布流，缩小玻璃层信息密度 */
  .card-glass { padding: 10px 12px 11px; }
  .card-glass h3 { font-size: 14.5px; }
  .card-glass .en { font-size: 11px; margin-bottom: 5px; }
  .card-glass .meta { font-size: 11.5px; }
  .card-glass .stats .cat { display: none; }
  .card:hover { transform: none; }

  .detail-hero { aspect-ratio: 4 / 3; }
  .hero-glass { padding: 14px 16px 16px; }
  /* 操作栏按钮多时（个人主页最多 7 个）才换行到独立一行；常见的「返回 + 单个点赞」
     不强制占满一整行，省下手机上寸土寸金的竖向空间 */
  .detail-top { flex-wrap: wrap; gap: 8px; }
  .detail-top > .btn { flex: 0 0 auto; }
  .detail-actions { flex: 0 1 auto; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
  .detail-actions .btn { flex: 0 1 auto; text-align: center; }
  .detail-float-actions .btn { flex: 0 1 auto; text-align: center; }
  .detail-pager { margin-right: 30px; }
  .detail-dots { right: 4px; gap: 12px; }
  .detail-dot.active .dot-label { max-width: 64px; font-size: 11px; }

  .spec-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .story-card { padding: 22px 20px 20px 24px; }
  .story-card p { font-size: 14.5px; }

  .form-grid { grid-template-columns: 1fr; }
  .form-actions .btn { flex: 1; padding: 12px; }
  .taste-score-grid { grid-template-columns: 1fr; }

  .search-row .input { max-width: none; }
  .sort-group { width: 100%; }
  .sort-group .chip { flex: 1; text-align: center; }

  .profile-head { padding: 20px; gap: 14px; }
  .avatar { width: 54px; height: 54px; font-size: 22px; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .profile-settings { grid-template-columns: 1fr; }
  .card-glass .stats { margin-top: 7px; font-size: 11px; }

  .modal { align-items: flex-end; padding: 0; }
  .modal-box {
    max-width: none;
    border-radius: var(--radius) var(--radius) 0 0;
    border-left: none; border-right: none; border-bottom: none;
    padding: 28px 22px calc(28px + env(safe-area-inset-bottom));
  }

  .btn, .chip, .input { min-height: 42px; }
  .btn-sm { min-height: 36px; }
  .btn-icon { min-height: 34px; }

  .site-footer { padding: 10px 16px calc(8px + env(safe-area-inset-bottom)); font-size: 10.5px; }
  .container { padding-bottom: 60px; }
}

/* 超窄屏（小手机 ≤400px）：压缩筛选/操作 chip 与统计块，避免元素变多后堆叠过高 */
@media (max-width: 400px) {
  .chip { padding: 6px 12px; font-size: 12.5px; }
  .stats-grid { gap: 6px; }
  .stat-tile { padding: 12px 4px; }
  .stat-tile .num { font-size: 19px; }
  .spec { padding: 10px 12px; }
  .admin-user-act .btn { padding: 6px 10px; }
  /* 顶栏「新建词条」只留图标，给 logo 和登录/注册按钮多留一点空间 */
  .topbar-actions .btn-label { display: none; }
  .topbar-actions .btn-primary { padding: 0; width: 36px; height: 36px; border-radius: 50%; }
}

/* 动效偏好：减少动态 */
@media (prefers-reduced-motion: reduce) {
  .card { animation: none; }
  .card-img, .hero-img { transform: none !important; }
  * { transition-duration: 0.01ms !important; }
}

/* ICP 备案页脚：工信部要求首页底部展示并可点击跳转，但不该一直占屏幕——
   固定在视口底部，默认收在屏幕外，只有真正拉到页面最底部才滑入；一旦往回翻页离开底部就自动收回，
   平时不占用/遮挡内容（见 app.js updateFooterVisibility） */
.site-footer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  text-align: center;
  padding: 12px 16px calc(10px + env(safe-area-inset-bottom));
  font-size: 11px;
  letter-spacing: 0.3px;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  transform: translateY(100%);
  transition: transform 0.25s var(--ease-out);
  pointer-events: none;
}
.site-footer.visible { transform: translateY(0); pointer-events: auto; }
.site-footer a {
  color: var(--text-faint);
  text-decoration: none;
  transition: color 0.2s ease;
}

/* 月历记账 */
.ucal-nav { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 4px 0 14px; }
.ucal-month { font-family: var(--font-display); font-size: 16px; font-weight: 700; min-width: 76px; text-align: center; }
.ucal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.ucal-weekdays { margin-bottom: 6px; }
.ucal-wd { text-align: center; font-size: 12px; color: var(--text-faint); }
.ucal-cell {
  position: relative; aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); background: var(--bg-elev); border: 1px solid var(--border);
  cursor: pointer; transition: border-color 0.2s ease;
}
.ucal-cell:hover { border-color: var(--border-strong); }
.ucal-cell.active { border-color: var(--accent); box-shadow: 0 0 0 1.5px var(--accent); }
.ucal-cell.ucal-empty { background: none; border: none; cursor: default; }
.ucal-day { font-size: 13px; }
.ucal-badge {
  position: absolute; bottom: 3px; right: 3px; min-width: 15px; height: 15px; padding: 0 3px;
  border-radius: 8px; background: var(--accent); color: #fff; font-size: 10px; line-height: 15px; text-align: center;
}
.ucal-day-card { margin: 14px 0; }
.ucal-day-head { font-size: 13px; color: var(--text-dim); margin-bottom: 10px; }
.ucal-entry { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.ucal-entry:last-child { border-bottom: none; }
.ucal-entry-name { flex: 1 1 auto; min-width: 0; font-size: 14px; }
.ucal-entry-qty { min-width: 20px; text-align: center; font-size: 14px; }
.ucal-add { margin-top: 10px; }
.ucal-matches { margin-top: 6px; max-height: 220px; overflow-y: auto; }
.ucal-match {
  padding: 9px 10px; font-size: 14px; border-radius: var(--radius-sm); cursor: pointer;
}
.ucal-match:hover { background: var(--bg-elev); }
.ucal-summary {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 16px 18px; margin-top: 18px;
}
.ucal-summary-head { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; font-size: 14px; color: var(--text-dim); margin-bottom: 10px; }
.ucal-summary-head b { color: var(--text); font-size: 16px; }
.ucal-summary-head b.ucal-cost { color: var(--accent); }
.ucal-mrow {
  display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 13.5px;
  border-bottom: 1px solid var(--border);
}
.ucal-mrow:last-child { border-bottom: none; }
.ucal-mname { flex: 1 1 auto; min-width: 0; }
.ucal-mml { flex: 0 0 auto; color: var(--text-dim); }
.ucal-mcost { flex: 0 0 70px; text-align: right; color: var(--accent); }
.site-footer a:hover { color: var(--text-dim); }
