/* ===== 寻萃集 · 高保真多彩卡片风格 ===== */
:root {
  /* 背景与表面 */
  --bg: #FFF8F0;
  --bg-warm: #FFF0E0;
  --surface: #FFFFFF;
  --surface-2: #FDF6EC;

  /* 文字 */
  --text: #3D2B1F;
  --text-soft: #8B7B6B;
  --text-faint: #B5A99A;

  /* 多彩卡片色 */
  --card-yellow: #FFE5B4;
  --card-pink: #FFD6E0;
  --card-mint: #C8E6C9;
  --card-sky: #B3E5FC;
  --card-lavender: #E1BEE7;
  --card-peach: #FFCCBC;

  /* 主色 */
  --accent: #FF8C42;
  --accent-dark: #E6732A;
  --accent-light: #FFB088;

  /* 形状 */
  --radius-sm: 12px;
  --radius-md: 20px;
  --radius-lg: 28px;
  --radius-xl: 36px;

  /* 阴影（分层，不统一） */
  --shadow-xs: 0 1px 3px rgba(61, 43, 31, 0.06);
  --shadow-sm: 0 4px 12px rgba(61, 43, 31, 0.08);
  --shadow-md: 0 8px 24px rgba(61, 43, 31, 0.10);
  --shadow-lg: 0 16px 48px rgba(61, 43, 31, 0.14);
  --shadow-card: 0 6px 20px rgba(61, 43, 31, 0.09), 0 2px 6px rgba(61, 43, 31, 0.05);

  /* 间距（4px 基数） */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* 字号 */
  --fs-xs: 12px;
  --fs-sm: 14px;
  --fs-base: 16px;
  --fs-lg: 20px;
  --fs-xl: 24px;
  --fs-2xl: 32px;
  --fs-3xl: 40px;

  /* 动效 */
  --ease: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body { height: 100%; }

body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  user-select: none;
  -webkit-font-smoothing: antialiased;
  /* 渐变网格背景，营造层次 */
  background-image:
    radial-gradient(ellipse 600px 400px at 10% -10%, rgba(255, 229, 180, 0.5), transparent 60%),
    radial-gradient(ellipse 500px 400px at 100% 0%, rgba(255, 214, 224, 0.4), transparent 60%),
    radial-gradient(ellipse 700px 500px at 50% 100%, rgba(200, 230, 201, 0.3), transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-warm) 100%);
  background-attachment: fixed;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* ===== 顶部栏 ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  background: rgba(255, 248, 240, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(61, 43, 31, 0.06);
  z-index: 10;
}
.logo { display: flex; align-items: center; gap: var(--space-3); }
.logo-icon {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border-radius: var(--radius-sm);
  color: white;
  box-shadow: 0 4px 12px rgba(255, 140, 66, 0.35);
}
.logo-text {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 2px;
  background: linear-gradient(135deg, var(--accent-dark), var(--text));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.logo-sub {
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: 3px;
  text-transform: uppercase;
  font-weight: 600;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, var(--card-mint), #A5D6A7);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: #2E7D32;
  box-shadow: var(--shadow-xs);
}

/* ===== 主内容区 ===== */
#mainContent {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 0 90px;
  scroll-behavior: smooth;
}
.module { display: none; padding: var(--space-6) var(--space-5) var(--space-10); max-width: 920px; margin: 0 auto; }
.module.active { display: block; animation: fadeUp 0.5s var(--ease-smooth); }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.module-header { margin-bottom: var(--space-6); }
.module-title {
  font-size: var(--fs-2xl);
  font-weight: 800;
  margin-bottom: var(--space-2);
  letter-spacing: -0.5px;
}
.module-desc {
  color: var(--text-soft);
  font-size: var(--fs-sm);
  line-height: 1.7;
}

/* ===== 模块一：器具卡片网格 ===== */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
}
.tool-card {
  position: relative;
  background: var(--card-yellow);
  border-radius: var(--radius-md);
  padding: var(--space-5) var(--space-4);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
  overflow: hidden;
  animation: cardIn 0.5s var(--ease) backwards;
}
.tool-card:nth-child(1) { background: var(--card-yellow); animation-delay: 0.05s; }
.tool-card:nth-child(2) { background: var(--card-pink); animation-delay: 0.1s; }
.tool-card:nth-child(3) { background: var(--card-mint); animation-delay: 0.15s; }
.tool-card:nth-child(4) { background: var(--card-sky); animation-delay: 0.2s; }
.tool-card:nth-child(5) { background: var(--card-lavender); animation-delay: 0.25s; }
.tool-card:nth-child(6) { background: var(--card-peach); animation-delay: 0.3s; }

@keyframes cardIn {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.tool-card:hover { transform: translateY(-6px) scale(1.02); box-shadow: var(--shadow-lg); }
.tool-card:active { transform: scale(0.97); }

.tool-card::before {
  content: '';
  position: absolute;
  top: -20px; right: -20px;
  width: 80px; height: 80px;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  pointer-events: none;
}

.tool-card .tool-icon {
  width: 90px;
  height: 90px;
  margin: 0 auto var(--space-3);
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.1));
}
.tool-card .tool-name {
  font-size: var(--fs-base);
  font-weight: 700;
  margin-bottom: var(--space-1);
}
.tool-card .tool-tag {
  display: inline-block;
  background: rgba(255, 255, 255, 0.7);
  padding: 2px 10px;
  border-radius: 10px;
  font-size: var(--fs-xs);
  color: var(--text-soft);
  font-weight: 600;
}
.tool-card .tool-desc {
  font-size: var(--fs-xs);
  color: var(--text-soft);
  margin-top: var(--space-2);
  line-height: 1.6;
}

/* ===== 模块二：学习布局 ===== */
.learn-layout {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.learn-side {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.side-title {
  font-size: var(--fs-sm);
  color: var(--text-soft);
  margin-bottom: var(--space-1);
  font-weight: 600;
}
.learn-tool-list {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  padding-bottom: var(--space-2);
  scrollbar-width: none;
}
.learn-tool-list::-webkit-scrollbar { display: none; }
.learn-tool-chip {
  flex-shrink: 0;
  padding: 10px 18px;
  background: var(--surface);
  border-radius: 20px;
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.25s var(--ease);
  white-space: nowrap;
  box-shadow: var(--shadow-xs);
}
.learn-tool-chip.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: white;
  border-color: var(--accent-dark);
  box-shadow: 0 4px 14px rgba(255, 140, 66, 0.35);
}
.learn-tool-chip:hover:not(.active) { transform: translateY(-2px); }
.learn-main {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: var(--space-6) var(--space-5);
  box-shadow: var(--shadow-sm);
  min-height: 420px;
  max-height: 68vh;
  overflow-y: auto;
}
.learn-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 360px;
  color: var(--text-faint);
  text-align: center;
  gap: var(--space-3);
}
.placeholder-icon {
  width: 80px; height: 80px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-warm);
  border-radius: 50%;
  color: var(--text-faint);
}

.learn-content .learn-hero {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  padding: var(--space-5);
  background: linear-gradient(135deg, var(--card-yellow), #FFD180);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
}
.learn-hero .hero-emoji { width: 110px; height: 110px; flex-shrink: 0; }
.learn-hero .hero-info h2 { font-size: var(--fs-xl); margin-bottom: var(--space-1); }
.learn-hero .hero-info p { font-size: var(--fs-sm); color: var(--text-soft); line-height: 1.6; }

.learn-section { margin-bottom: var(--space-6); }
.learn-section h3 {
  font-size: var(--fs-base);
  margin-bottom: var(--space-3);
  padding-left: var(--space-3);
  border-left: 4px solid var(--accent);
  font-weight: 700;
}
.learn-section p, .learn-section li {
  font-size: var(--fs-sm);
  line-height: 1.9;
  color: var(--text);
}
.learn-section ul { padding-left: var(--space-5); }
.learn-section ul li { margin-bottom: var(--space-2); }
.learn-section ol { padding-left: var(--space-5); }
.learn-section ol li { margin-bottom: var(--space-2); }

.structure-diagram {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
}
.structure-part {
  background: var(--card-mint);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: #2E7D32;
}

.unlock-btn {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--fs-base);
  font-weight: 700;
  cursor: pointer;
  margin-top: var(--space-6);
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 6px 20px rgba(255, 140, 66, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}
.unlock-btn:active { transform: scale(0.97); }
.unlock-btn:disabled {
  background: linear-gradient(135deg, #D7CCC8, #BCAAA4);
  box-shadow: none;
  cursor: not-allowed;
}
.unlock-status {
  text-align: center;
  padding: 16px;
  background: linear-gradient(135deg, var(--card-mint), #A5D6A7);
  border-radius: var(--radius-md);
  font-weight: 700;
  color: #2E7D32;
  margin-top: var(--space-6);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

/* ===== 模块三：冲煮工坊 ===== */
.brew-selector { padding: var(--space-2) 0; }
.selector-title {
  font-size: var(--fs-sm);
  color: var(--text-soft);
  margin-bottom: var(--space-4);
  font-weight: 600;
}
.brew-tool-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
}
.brew-tool-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: var(--space-6) var(--space-4);
  text-align: center;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: transform 0.3s var(--ease), box-shadow 0.3s;
  position: relative;
  border: 2px solid transparent;
}
.brew-tool-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent-light);
  box-shadow: var(--shadow-md);
}
.brew-tool-card .emoji { width: 80px; height: 80px; margin: 0 auto var(--space-2); }
.brew-tool-card .name { font-weight: 700; font-size: var(--fs-base); }
.brew-tool-card .skin-tag {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  font-size: 10px;
  background: linear-gradient(135deg, var(--card-lavender), #CE93D8);
  color: #6A1B9A;
  padding: 3px 8px;
  border-radius: 10px;
  font-weight: 700;
}
.brew-tool-card.locked { opacity: 0.5; cursor: not-allowed; }

.brew-stage {
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.brew-stage.hidden { display: none; }

.brew-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  background: linear-gradient(135deg, var(--bg-warm), var(--surface));
  gap: var(--space-3);
  flex-wrap: wrap;
}
.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border: 2px solid var(--text-faint);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 14px;
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.brew-progress { display: flex; align-items: center; gap: var(--space-2); flex: 1; min-width: 120px; }
.progress-bar {
  flex: 1;
  height: 8px;
  background: #E8DDD0;
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-light), var(--accent));
  border-radius: 4px;
  transition: width 0.5s var(--ease);
  width: 0;
}
.progress-text { font-size: var(--fs-xs); font-weight: 700; white-space: nowrap; color: var(--text-soft); }

.skin-switcher { display: flex; gap: var(--space-2); }
.skin-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: all 0.25s var(--ease);
  box-shadow: var(--shadow-xs);
}
.skin-dot.active {
  border-color: var(--accent);
  transform: scale(1.15);
  box-shadow: 0 0 0 3px rgba(255, 140, 66, 0.2);
}

/* ===== 冲煮画布 ===== */
.brew-canvas {
  position: relative;
  width: 100%;
  max-width: 400px;
  height: 400px;
  margin: 0 auto;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(255, 255, 255, 0.6), transparent 60%),
    linear-gradient(180deg, #FFF5E6 0%, #FFE8CC 100%);
  overflow: hidden;
}
/* 桌面装饰圆点 */
.brew-canvas::before {
  content: '';
  position: absolute;
  top: 10%; left: 8%;
  width: 60px; height: 60px;
  background: rgba(255, 229, 180, 0.5);
  border-radius: 50%;
}
.brew-canvas::after {
  content: '';
  position: absolute;
  bottom: 15%; right: 10%;
  width: 80px; height: 80px;
  background: rgba(255, 214, 224, 0.4);
  border-radius: 50%;
}

.scene-item {
  position: absolute;
  transition: transform 0.3s var(--ease);
  cursor: grab;
  touch-action: none;
  z-index: 5;
}
.scene-item.dragging { cursor: grabbing; transition: none; z-index: 50; }
.scene-item.clickable { cursor: pointer; }

/* SVG 器具尺寸控制 */
.svg-tool {
  width: 100%;
  height: 100%;
  display: block;
}

/* 器具包装尺寸 */
.tool-scale { width: 110px; height: 90px; }
.tool-dripper { width: 90px; height: 90px; }
.tool-kettle { width: 100px; height: 100px; }
.tool-beans { width: 70px; height: 70px; }
.tool-grinder { width: 90px; height: 130px; }
.tool-server { width: 80px; height: 100px; }
.tool-fp { width: 90px; height: 120px; }
.tool-moka { width: 100px; height: 130px; }

/* 计时器徽章 */
.timer-badge {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(61, 43, 31, 0.85);
  color: white;
  padding: 8px 20px;
  border-radius: 20px;
  font-family: "SF Mono", monospace;
  font-size: 18px;
  font-weight: 700;
  z-index: 30;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(8px);
}

/* 步骤提示卡 */
.brew-instruction {
  padding: var(--space-4) var(--space-5);
  background: linear-gradient(135deg, var(--card-sky), #81D4FA);
  border-top: 1px solid rgba(0,0,0,0.04);
}
.instruction-step {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: #01579B;
  margin-bottom: var(--space-1);
  letter-spacing: 0.5px;
}
.instruction-desc {
  font-size: var(--fs-base);
  font-weight: 700;
  margin-bottom: var(--space-1);
}
.instruction-tip {
  font-size: var(--fs-xs);
  color: var(--text-soft);
  line-height: 1.6;
}

/* AI 提示气泡 */
.ai-hint-bubble {
  position: absolute;
  top: 60px;
  right: 16px;
  background: linear-gradient(135deg, var(--card-lavender), #CE93D8);
  border-radius: 18px;
  padding: var(--space-3) var(--space-4);
  max-width: 260px;
  box-shadow: var(--shadow-lg);
  z-index: 60;
  animation: popIn 0.4s var(--ease);
}
.ai-hint-bubble.hidden { display: none; }
@keyframes popIn {
  from { transform: scale(0.8) translateY(-10px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}
.ai-hint-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: #6A1B9A;
  margin-bottom: 6px;
}
.ai-hint-content { font-size: var(--fs-sm); line-height: 1.7; color: var(--text); }
.ai-hint-close {
  background: var(--accent);
  color: white;
  border: none;
  padding: 6px 14px;
  border-radius: 14px;
  font-size: var(--fs-xs);
  font-weight: 700;
  cursor: pointer;
  margin-top: var(--space-2);
}

/* 完成庆祝 */
.brew-complete {
  position: fixed;
  inset: 0;
  background: rgba(61, 43, 31, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: var(--space-5);
  backdrop-filter: blur(4px);
}
.brew-complete.hidden { display: none; }
.complete-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: var(--space-8) var(--space-6);
  text-align: center;
  max-width: 360px;
  width: 100%;
  animation: popIn 0.5s var(--ease);
  box-shadow: var(--shadow-lg);
}
.complete-emoji { font-size: 56px; margin-bottom: var(--space-3); animation: bounce 1s infinite; }
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.complete-card h2 { font-size: var(--fs-xl); margin-bottom: var(--space-2); }
.complete-card p { color: var(--text-soft); margin-bottom: var(--space-4); line-height: 1.6; }
.skin-preview {
  display: flex;
  justify-content: center;
  gap: var(--space-3);
  margin: var(--space-5) 0;
}
.skin-preview-item {
  width: 80px; height: 80px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  border: 3px dashed var(--accent);
  animation: spin 3s linear infinite;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ===== 模块四：AI 答疑 ===== */
.ai-layout {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 220px);
  min-height: 420px;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.chat-msg {
  display: flex;
  gap: var(--space-2);
  max-width: 85%;
  animation: fadeUp 0.3s var(--ease-smooth);
}
.chat-msg.ai { align-self: flex-start; }
.chat-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chat-msg.ai .msg-avatar {
  background: linear-gradient(135deg, var(--card-lavender), #CE93D8);
  color: #6A1B9A;
}
.chat-msg.user .msg-avatar {
  background: linear-gradient(135deg, var(--card-mint), #A5D6A7);
  color: #2E7D32;
}
.msg-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: var(--fs-sm);
  line-height: 1.7;
  word-break: break-word;
  box-shadow: var(--shadow-xs);
}
.chat-msg.ai .msg-bubble {
  background: var(--surface);
  border-top-left-radius: 4px;
}
.chat-msg.user .msg-bubble {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: white;
  border-top-right-radius: 4px;
}
.msg-bubble.typing::after {
  content: '...';
  animation: typing 1.2s infinite;
}
@keyframes typing {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

.chat-input-area {
  padding: var(--space-3) var(--space-4);
  background: rgba(255, 248, 240, 0.9);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(61, 43, 31, 0.06);
}
.quick-questions {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  margin-bottom: var(--space-3);
  scrollbar-width: none;
}
.quick-questions::-webkit-scrollbar { display: none; }
.quick-q {
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid #E8DDD0;
  padding: 8px 14px;
  border-radius: 16px;
  font-size: var(--fs-xs);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  font-weight: 500;
}
.quick-q:hover { background: var(--card-yellow); border-color: var(--accent-light); }
.chat-input-row {
  display: flex;
  gap: var(--space-2);
}
#chatInput {
  flex: 1;
  padding: 14px 18px;
  border: 2px solid #E8DDD0;
  border-radius: 22px;
  font-size: var(--fs-sm);
  outline: none;
  background: var(--surface);
  transition: border-color 0.2s;
}
#chatInput:focus { border-color: var(--accent); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: white;
  border: none;
  padding: 0 22px;
  border-radius: 22px;
  font-size: var(--fs-sm);
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 14px rgba(255, 140, 66, 0.3);
  transition: transform 0.2s;
}
.btn-primary:active { transform: scale(0.95); }

/* ===== 底部导航（移动端）液态小球 ===== */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-around;
  align-items: center;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  box-shadow: 0 -4px 24px rgba(61, 43, 31, 0.08);
  z-index: 50;
  padding: 14px 0 calc(14px + env(safe-area-inset-bottom, 0));
}
/* 指示器层：轨道 + 小球，轨道顶部带半圆凹口 */
/* 凹口位置变量：注册后可参与过渡动画（凹口和小球同步滑动） */
@property --ball-x {
  syntax: '<length>';
  inherits: false;
  initial-value: 60px;
}
.nav-indicator {
  position: absolute;
  left: 0; right: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 60px;
  pointer-events: none;
  z-index: 0;
}
.nav-track {
  position: absolute;
  left: 14px; right: 14px;
  top: 50%;
  transform: translateY(-50%);
  height: 46px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border-radius: 23px;
  box-shadow: 0 6px 18px rgba(255, 140, 66, 0.35);
  /* 与小球同心的圆形镂空（半径比球大 4px），形成"白球卡在橙色坑里"的一圈缝隙 */
  -webkit-mask-image: radial-gradient(circle 25px at var(--ball-x) 0, transparent 24px, #000 25px);
  mask-image: radial-gradient(circle 25px at var(--ball-x) 0, transparent 24px, #000 25px);
  transition: --ball-x 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
/* 悬浮内容层：图标落在橙色轨道的半圆凹坑中心（白色背景透出当底色），文字在轨道上 */
.nav-float {
  position: absolute;
  top: calc(50% - 23px);
  left: 16.66%;
  width: 42px;
  height: 42px;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: left 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.nav-float .float-icon {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent-dark);
}
.nav-float .float-icon svg { display: block; }
.nav-float .float-label {
  position: absolute;
  top: 46px; /* 球下方，落在橙色轨道上 */
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
}
.bottom-nav .nav-item {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 0;
  background: none;
  border: none;
  cursor: pointer;
  gap: 3px;
  color: var(--text-faint);
  transition: color 0.2s;
}
.bottom-nav .nav-icon {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
}
.bottom-nav .nav-label { font-size: 10px; font-weight: 600; }
.bottom-nav .nav-item.active { color: var(--accent-dark); }
/* 选中的图标文字交给悬浮层（跟随白球滑动），静态内容隐藏 */
.bottom-nav .nav-item.active .nav-icon,
.bottom-nav .nav-item.active .nav-label { opacity: 0; }

/* ===== 侧边导航（桌面端） ===== */
.side-nav {
  display: none;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: 230px;
  background: rgba(250, 246, 240, 0.92);
  backdrop-filter: blur(16px);
  box-shadow: 4px 0 30px rgba(61, 43, 31, 0.06);
  flex-direction: column;
  padding: var(--space-8) var(--space-4);
  gap: var(--space-2);
  z-index: 50;
}
.side-nav .nav-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-3) var(--space-6);
  margin-bottom: var(--space-4);
  border-bottom: 1px solid rgba(61, 43, 31, 0.06);
}
.side-nav .nav-item {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 14px var(--space-4);
  background: none;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  font-size: var(--fs-sm);
  text-align: left;
  color: var(--text-soft);
  font-weight: 600;
  transition: color 0.25s var(--ease);
}
.side-nav .nav-item:hover { background: rgba(255, 140, 66, 0.08); color: var(--text); }
.side-nav .nav-item.active {
  background: transparent;
  color: #fff;
}
/* 选中项内容交给悬浮层（跟随白球滑动），静态内容隐藏 */
.side-nav .nav-item.active > * { opacity: 0; }
.side-nav .nav-icon {
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
}

/* 侧边栏滑动指示器：白色圆角长条随点击上下移动 */
.side-indicator {
  position: absolute;
  left: 16px; right: 16px;
  top: 0;
  pointer-events: none;
  z-index: 0;
}
.side-track { display: none; }
.side-ball {
  position: absolute;
  left: 0; right: 0;
  top: var(--side-ball-y, 140px);
  height: 48px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 6px 16px rgba(61, 43, 31, 0.12), 0 2px 4px rgba(61, 43, 31, 0.06);
  transform: translateY(-50%);
  transition: top 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
/* 悬浮内容层：图标+文字跟白色长条一起滑动 */
.side-float {
  position: absolute;
  left: 16px; right: 16px;
  top: var(--side-ball-y, 140px);
  height: 48px;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-4);
  pointer-events: none;
  transition: top 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.side-float .float-icon {
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent-dark);
}
.side-float .float-icon svg { display: block; }
.side-float .float-label {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--accent-dark);
  white-space: nowrap;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(61, 43, 31, 0.92);
  color: white;
  padding: 12px 24px;
  border-radius: 24px;
  font-size: var(--fs-sm);
  z-index: 200;
  opacity: 0;
  transition: all 0.3s var(--ease);
  pointer-events: none;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.hidden { display: none !important; }

/* ===== 悬浮 AI 小助手 ===== */
.ai-float {
  position: fixed;
  bottom: 90px;
  right: 20px;
  z-index: 80;
}
@media (min-width: 900px) {
  .ai-float { bottom: 30px; right: 30px; }
}
.ai-float-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 8px 24px rgba(255, 140, 66, 0.45);
  transition: transform 0.3s var(--ease), box-shadow 0.3s;
  position: relative;
}
.ai-float-btn:hover { transform: scale(1.1) rotate(10deg); box-shadow: 0 12px 30px rgba(255, 140, 66, 0.55); }
.ai-float-btn:active { transform: scale(0.95); }
.ai-float-dot {
  position: absolute;
  top: 4px; right: 4px;
  width: 10px; height: 10px;
  background: #4CAF50;
  border-radius: 50%;
  border: 2px solid white;
}
.ai-panel {
  position: absolute;
  bottom: 70px;
  right: 0;
  width: 340px;
  max-width: calc(100vw - 32px);
  max-height: 70vh;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: panelUp 0.3s var(--ease);
}
.ai-panel.open { display: flex; }
/* 手机端：保持悬浮小窗，缩小宽度并适配键盘 */
@media (max-width: 899px) {
  .ai-panel {
    width: min(340px, 92vw);
    max-height: 65dvh;
    bottom: 64px;
  }
  .ai-panel .chat-messages { min-height: 140px; max-height: 50dvh; }
}
@keyframes panelUp {
  from { opacity: 0; transform: translateY(16px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.ai-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: white;
}
.ai-panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: var(--fs-base);
}
.ai-panel-close {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  width: 28px; height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s;
}
.ai-panel-close:hover { background: rgba(255,255,255,0.2); }
.ai-panel .chat-messages {
  flex: 1;
  min-height: 240px;
  max-height: 45vh;
  overflow-y: auto;
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  background: var(--bg);
}
.ai-panel .chat-input-area {
  padding: var(--space-3);
  background: var(--surface);
  border-top: 1px solid rgba(0,0,0,0.05);
  flex-shrink: 0;
}
@media (max-width: 899px) {
  .ai-panel .chat-messages { min-height: 140px; max-height: 50dvh; }
}

/* 磨豆机手柄旋转 */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.grinder-handle-svg {
  transform-origin: 100px 14px;
  cursor: pointer;
}

/* 水流动画 */
@keyframes waterFlow {
  from { background-position: 0 0; }
  to { background-position: 0 20px; }
}

/* ===== 桌面端适配 ===== */
@media (min-width: 900px) {
  #app { flex-direction: row; }
  .topbar {
    position: fixed;
    top: 0; left: 230px; right: 0;
    z-index: 40;
  }
  .side-nav { display: flex; }
  .bottom-nav { display: none; }
  #mainContent {
    margin-left: 230px;
    padding: 90px var(--space-10) var(--space-10);
    height: 100vh;
  }
  .module { max-width: 1000px; padding: 0 0 var(--space-12); }

  .tool-grid { grid-template-columns: repeat(3, 1fr); }
  .brew-tool-grid { grid-template-columns: repeat(3, 1fr); }

  .learn-layout { flex-direction: row; align-items: flex-start; gap: var(--space-6); }
  .learn-side {
    width: 220px;
    flex-shrink: 0;
    position: sticky;
    top: 110px;
  }
  .learn-tool-list { flex-direction: column; overflow: visible; }
  .learn-tool-chip { text-align: center; }
  .learn-main { flex: 1; }

  .brew-canvas { height: 480px; }
  .ai-layout { height: calc(100vh - 260px); }
}

/* 平板 */
@media (min-width: 600px) and (max-width: 899px) {
  .tool-grid { grid-template-columns: repeat(3, 1fr); }
}

/* 超小屏 */
@media (max-width: 360px) {
  .tool-grid { grid-template-columns: repeat(2, 1fr); }
  .module-title { font-size: var(--fs-xl); }
}

/* ===== 模式选择 ===== */
.mode-selector {
  animation: fadeUp 0.3s ease;
}
.mode-back {
  color: var(--text-soft);
  cursor: pointer;
  margin-bottom: 16px;
  font-size: 14px;
  display: inline-block;
}
.mode-back:hover { color: var(--primary); }
.mode-title {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--text);
  margin-bottom: 24px;
  text-align: center;
}
.mode-cards {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}
.mode-card {
  background: var(--bg-card);
  border-radius: 20px;
  padding: 32px 28px;
  width: 220px;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: all 0.2s ease;
  position: relative;
}
.mode-card:hover:not(.locked) {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}
.mode-card.locked { opacity: 0.5; cursor: not-allowed; }
.mode-icon { font-size: 40px; margin-bottom: 12px; }
.mode-name { font-size: var(--fs-md); font-weight: 700; color: var(--text); margin-bottom: 6px; }
.mode-desc { font-size: 13px; color: var(--text-soft); line-height: 1.5; }
.mode-lock {
  position: absolute;
  top: 12px; right: 12px;
  background: var(--warn);
  color: white;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 10px;
}

/* ===== 自由冲煮 ===== */
.free-brew {
  animation: fadeUp 0.3s ease;
}
.free-title {
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--text);
}
.customer-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border-radius: 16px;
  padding: 12px 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}
.customer-avatar {
  font-size: 28px;
  background: var(--bg-warm);
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.customer-bubble {
  background: var(--bg-warm);
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
  flex: 1;
}
.free-canvas {
  position: relative;
  width: 100%;
  max-width: 400px;
  height: 420px;
  background: var(--bg-canvas);
  border-radius: 16px;
  overflow: visible;
  margin: 0 auto 12px;
  box-shadow: inset var(--shadow-xs);
}
.free-controls {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
}
.param-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
}
.param-item label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-soft);
  margin-bottom: 6px;
}
.param-val { color: var(--primary); font-weight: 600; }
.param-item input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
}
.param-range {
  font-size: 11px;
  color: var(--text-faint);
  text-align: center;
  margin-top: 2px;
}
.serve-btn {
  width: 100%;
  padding: 14px;
  font-size: var(--fs-md);
  font-weight: 700;
}

/* ===== 客人评价 ===== */
.customer-result {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.3s ease;
  padding: 20px;
}
.result-card {
  background: var(--bg-card);
  border-radius: 24px;
  padding: 32px 28px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.result-emoji { font-size: 64px; margin-bottom: 12px; }
.result-comment {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--text);
  margin-bottom: 20px;
  line-height: 1.4;
}
.result-taste {
  background: var(--bg-warm);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 20px;
  text-align: left;
}
.taste-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 13px;
}
.taste-bar:last-child { margin-bottom: 0; }
.taste-bar span {
  width: 40px;
  color: var(--text-soft);
  flex-shrink: 0;
}
.taste-track {
  flex: 1;
  height: 8px;
  background: rgba(0,0,0,0.08);
  border-radius: 4px;
  overflow: hidden;
}
.taste-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}
.taste-fill.sour { background: linear-gradient(90deg, #FFD54F, #FF7043); }
.taste-fill.bitter { background: linear-gradient(90deg, #8D6E63, #3E2723); }
.taste-fill.strong { background: linear-gradient(90deg, #42A5F5, #1565C0); }
.taste-fill.balance { background: linear-gradient(90deg, #66BB6A, #2E7D32); }
.result-actions {
  display: flex;
  gap: 10px;
}
.result-actions button { flex: 1; }

@keyframes popIn {
  0% { transform: scale(0.7); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
