/* =========================================================
   手冲手记 · 样式表  v2
   美学方向：精品咖啡手帐 / 实验记录本
   奶油纸底 · 浓缩咖啡棕 · 铜壶赭橘 · 数据用等宽字体
   更新：全面微交互 + 呼吸感布局 + 云同步面板重设计
   ========================================================= */

/* ---------- 设计变量 ---------- */
:root {
  --paper:      #efe6d6;
  --paper-2:    #f7f0e3;
  --ink:        #2a1c12;
  --ink-soft:   #6f5a48;
  --line:       #d8c8b0;
  --hairline:   rgba(42, 28, 18, .10);
  --accent:     #b85c38;
  --accent-dk:  #8f4427;
  --gold:       #c08a3e;
  --good:       #5b7f5a;
  --warn:       #c0572d;
  --shadow:     0 30px 70px -42px rgba(42, 28, 18, .55);
  --shadow-md:  0 8px 30px -12px rgba(42, 28, 18, .35);
  --shadow-sm:  0 2px 0 rgba(42, 28, 18, .03);
  --radius-sm:  10px;
  --radius-md:  14px;
  --radius-lg:  18px;
  --radius-xl:  24px;
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out:    cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);

  --font-display: "Fraunces", "Songti SC", "STSong", Georgia, serif;
  --font-body:    "Hanken Grotesk", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono:    "Spline Sans Mono", "Cascadia Code", ui-monospace, monospace;
}

/* ---------- 微标签 ---------- */
.u-label {
  font-family: var(--font-mono);
  font-size: 10.5px; font-weight: 500;
  letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-soft);
}

/* ---------- 基础重置 ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 110% -10%, rgba(184, 92, 56, .10), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(192, 138, 62, .10), transparent 60%),
    var(--paper);
  line-height: 1.5;
  /* iPhone 刘海 + 底部横条安全区 */
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* ---------- 纸张噪点纹理 ---------- */
.grain {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .16;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}
.site-header, .tabs, .content, .site-footer, .toast-container { position: relative; z-index: 1; }

/* ---------- 顶部 ---------- */
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  max-width: 1120px; margin: 0 auto; padding: 36px 28px 12px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  font-size: 30px; width: 56px; height: 56px; flex: none;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--ink); color: var(--paper);
  box-shadow: var(--shadow);
  transition: transform 0.3s var(--ease-spring);
}
.brand-mark:hover { transform: scale(1.08) rotate(-5deg); }
.brand-text h1 {
  margin: 0; font-family: var(--font-display);
  font-weight: 600; font-size: clamp(28px, 5vw, 40px);
  letter-spacing: -.02em; line-height: 1;
}
.tagline { margin: 6px 0 0; color: var(--ink-soft); font-size: 14px; font-style: italic; }

.toolbar { display: flex; align-items: center; gap: 8px; }

/* ---------- 按钮体系 ---------- */
.btn {
  font-family: var(--font-body); font-size: 14px; font-weight: 600;
  padding: 10px 18px; border-radius: 999px; cursor: pointer;
  border: 1.5px solid var(--ink);
  transition: transform 0.18s var(--ease-spring), background 0.2s, color 0.2s, box-shadow 0.25s, border-color 0.2s;
}
.btn:active { transform: scale(0.96); }
.btn-solid { background: var(--ink); color: var(--paper); }
.btn-solid:hover { background: var(--accent-dk); border-color: var(--accent-dk); box-shadow: var(--shadow-md); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--ink); background: rgba(42,28,18,.04); }
.btn-back {
  background: none; border: none; color: var(--ink-soft); cursor: pointer;
  font-family: var(--font-body); font-size: 15px; font-weight: 600;
  padding: 6px 0; margin-bottom: 10px;
  transition: color 0.2s, transform 0.2s;
}
.btn-back:hover { color: var(--accent); transform: translateX(-3px); }
.btn-mini {
  font-size: 12.5px; font-weight: 600; padding: 5px 12px; border-radius: 999px;
  border: 1.5px solid var(--line); background: transparent; color: var(--ink-soft); cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.btn-mini:hover { border-color: var(--ink); color: var(--ink); }
.btn-mini.danger:hover { border-color: var(--accent); color: var(--accent); background: rgba(184,92,56,.06); }

/* 保存成功闪烁 */
@keyframes save-flash {
  0%   { background: var(--good); border-color: var(--good); color: #fff; }
  100% { background: var(--ink); border-color: var(--ink); color: var(--paper); }
}
.btn-saved { animation: save-flash 1.2s ease-out; }

/* ---------- 同步指示器（header 右侧按钮，点击打开弹窗） ---------- */
.sync-indicator {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-body); font-size: 12px; font-weight: 500;
  color: var(--ink-soft); cursor: pointer; padding: 7px 14px;
  border-radius: 999px; border: 1.5px solid transparent;
  background: transparent;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
  user-select: none;
}
.sync-indicator:hover { border-color: var(--line); background: var(--paper); color: var(--ink); }
.sync-indicator .sync-dot {
  width: 7px; height: 7px; border-radius: 50%; flex: none;
  background: var(--line);
  transition: background 0.3s;
}
.sync-indicator.enabled .sync-dot { background: var(--good); }
.sync-indicator.syncing .sync-dot { animation: sync-pulse 0.8s ease-in-out infinite; }
.sync-indicator.error .sync-dot { background: var(--warn); }
.sync-indicator.enabled { color: var(--ink); }

@keyframes sync-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .4; transform: scale(.7); }
}

/* ---------- 标签页 ---------- */
.tabs {
  display: flex; gap: 0; max-width: 1120px;
  margin: 18px auto 0; padding: 0 28px;
  border-bottom: 1.5px solid var(--line);
  position: relative;
}
/* 滑动下划线（CSS 自定义属性由 JS 在标签切换时更新） */
.tabs::after {
  content: ""; position: absolute; bottom: -1.5px;
  left: var(--il, 0px); width: var(--iw, 60px);
  height: 2.5px; border-radius: 2px;
  background: var(--accent);
  transition: left 0.3s var(--ease-out), width 0.3s var(--ease-out);
  pointer-events: none;
}
.tab {
  position: relative; display: flex; align-items: center; gap: 8px;
  background: none; border: none; cursor: pointer;
  font-family: var(--font-display); font-size: 19px; font-weight: 600;
  color: var(--ink-soft); padding: 14px 20px;
  transition: color 0.25s;
}
.tab:hover { color: var(--ink); }
.tab .tab-count {
  font-family: var(--font-mono); font-size: 12px; font-weight: 500;
  background: var(--line); color: var(--ink); border-radius: 999px; padding: 1px 8px;
  transition: background 0.25s, color 0.25s, transform 0.25s var(--ease-spring);
}
.tab.is-active { color: var(--ink); }
.tab.is-active .tab-count { background: var(--accent); color: var(--paper); transform: scale(1.08); }

/* ---------- 内容区 ---------- */
.content { max-width: 1120px; margin: 0 auto; padding: 40px 28px 80px; }
.view { display: none; animation: fade-up .35s var(--ease-out) both; }
.view.is-active { display: block; }
@keyframes fade-up { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* 列表项交错入场 */
@keyframes card-in {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: none; }
}
.bean-card.stagger-in, .brew-card.stagger-in {
  animation: card-in 0.4s var(--ease-out) both;
}
/* 通过 CSS 变量控制每张卡片的延迟 */
.bean-card.stagger-in:nth-child(1), .brew-card.stagger-in:nth-child(1) { animation-delay: 0ms; }
.bean-card.stagger-in:nth-child(2), .brew-card.stagger-in:nth-child(2) { animation-delay: 50ms; }
.bean-card.stagger-in:nth-child(3), .brew-card.stagger-in:nth-child(3) { animation-delay: 100ms; }
.bean-card.stagger-in:nth-child(4), .brew-card.stagger-in:nth-child(4) { animation-delay: 150ms; }
.bean-card.stagger-in:nth-child(5), .brew-card.stagger-in:nth-child(5) { animation-delay: 200ms; }
.bean-card.stagger-in:nth-child(6), .brew-card.stagger-in:nth-child(6) { animation-delay: 250ms; }
.bean-card.stagger-in:nth-child(n+7), .brew-card.stagger-in:nth-child(n+7) { animation-delay: 300ms; }

.view-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.view-title {
  margin: 0; font-family: var(--font-display); font-weight: 600;
  font-size: clamp(22px, 4vw, 30px); letter-spacing: -.01em;
}

/* ---------- 咖啡豆卡片网格 ---------- */
.beans-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 24px; }
.bean-card {
  position: relative; background: var(--paper-2); border: 1px solid var(--hairline);
  border-radius: var(--radius-xl); padding: 28px; cursor: pointer; overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.3s var(--ease-spring), box-shadow 0.35s ease, border-color 0.25s;
}
.bean-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow);
  border-color: rgba(184,92,56,.25);
}
.bean-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--accent); transform: scaleY(0); transform-origin: top;
  transition: transform 0.3s var(--ease-spring);
}
.bean-card:hover::before { transform: scaleY(1); }
.bean-card .bean-name {
  font-family: var(--font-display); font-size: 23px; font-weight: 600; line-height: 1.15;
  margin: 0 0 4px; letter-spacing: -.01em;
}
.bean-card .bean-roaster { color: var(--ink-soft); font-size: 13.5px; margin-bottom: 18px; }

/* 豆子余量进度 */
.bean-usage { margin: 14px 0 4px; }
.bean-usage .usage-bar {
  height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; margin-bottom: 6px;
}
.bean-usage .usage-fill {
  height: 100%; border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  transition: width 0.6s var(--ease-out);
}
.bean-usage .usage-text {
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 500;
  color: var(--ink-soft); letter-spacing: .04em;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.chip {
  font-size: 11px; letter-spacing: .03em; padding: 3px 11px; border-radius: 999px;
  background: rgba(184, 92, 56, .08); color: var(--accent-dk); border: 1px solid rgba(184, 92, 56, .20);
}
.bean-stats { display: flex; gap: 24px; padding-top: 18px; border-top: 1px solid var(--hairline); }
.stat .stat-num { font-family: var(--font-mono); font-size: 28px; font-weight: 600; line-height: 1; letter-spacing: -.01em; }
.stat .stat-label {
  font-family: var(--font-mono); font-size: 10px; font-weight: 500;
  letter-spacing: .14em; text-transform: uppercase; color: var(--ink-soft); margin-top: 6px;
}
.stat .stat-num.accent { color: var(--accent); }

/* ---------- 冲煮记录列表 ---------- */
.filter-bar { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 20px; }
.field-inline { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-soft); }
.field-inline select {
  font-family: var(--font-body); font-size: 14px; color: var(--ink);
  padding: 8px 14px; border-radius: var(--radius-sm); border: 1.5px solid var(--line);
  background: var(--paper-2); cursor: pointer;
  transition: border-color 0.2s;
}
.field-inline select:hover { border-color: var(--accent); }

.brews-list { display: flex; flex-direction: column; gap: 20px; }
.brew-card {
  display: grid; grid-template-columns: 110px 1fr auto; gap: 24px; align-items: center;
  background: var(--paper-2); border: 1px solid var(--hairline); border-radius: var(--radius-lg);
  padding: 24px 28px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.25s, box-shadow 0.35s, transform 0.3s var(--ease-spring);
}
.brew-card:hover {
  border-color: rgba(184,92,56,.2);
  box-shadow: var(--shadow);
  transform: translateY(-3px);
}
.brew-ratio {
  text-align: center; padding-right: 22px; border-right: 1px solid var(--hairline);
}
.brew-ratio .ratio-num {
  font-family: var(--font-mono); font-size: 24px; font-weight: 600;
  color: var(--accent); letter-spacing: -.01em;
  transition: transform 0.25s var(--ease-spring);
}
.brew-card:hover .brew-ratio .ratio-num { transform: scale(1.06); }
.brew-ratio .ratio-label {
  font-family: var(--font-mono); font-size: 9.5px; font-weight: 500;
  letter-spacing: .16em; text-transform: uppercase; color: var(--ink-soft); margin-top: 4px;
}
.brew-main .brew-bean { font-family: var(--font-display); font-size: 19px; font-weight: 600; letter-spacing: -.01em; }
.brew-meta { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 10px; font-size: 11px; letter-spacing: .04em; color: var(--ink-soft); }
.brew-meta span { display: inline-flex; align-items: baseline; gap: 6px; text-transform: uppercase; }
.brew-meta b { font-family: var(--font-mono); font-weight: 600; color: var(--ink); font-size: 13px; letter-spacing: 0; text-transform: none; }
.brew-notes { margin-top: 10px; font-size: 13.5px; color: var(--ink-soft); font-style: italic; max-width: 60ch; }
.brew-side { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.brew-date { font-family: var(--font-mono); font-size: 12px; color: var(--ink-soft); }
.row-actions { display: flex; gap: 6px; }

/* 评分徽章 */
.rating-badge {
  display: inline-flex; align-items: baseline; gap: 2px;
  font-family: var(--font-mono); font-weight: 600;
  background: var(--ink); color: var(--paper); padding: 5px 11px; border-radius: 8px;
  transition: transform 0.25s var(--ease-spring);
}
.rating-badge:hover { transform: scale(1.08); }
.rating-badge .r-num { font-size: 17px; }
.rating-badge .r-max { font-size: 11px; opacity: .65; }
.rating-badge.high { background: var(--good); }
.rating-badge.none { background: var(--line); color: var(--ink-soft); }

/* ---------- 空状态 ---------- */
.empty {
  text-align: center; padding: 56px 20px; color: var(--ink-soft);
  border: 1.5px dashed var(--line); border-radius: var(--radius-lg);
  background: rgba(247, 240, 227, .5);
}
.empty .empty-emoji { font-size: 42px; }
.empty p { margin: 12px 0 0; font-family: var(--font-display); font-size: 18px; }
.empty small { display: block; margin-top: 4px; font-size: 13px; }

/* ---------- 单豆详情 ---------- */
.detail-head {
  background: var(--ink); color: var(--paper); border-radius: var(--radius-xl);
  padding: 36px 36px; margin-bottom: 28px;
  box-shadow: var(--shadow);
}
.detail-head h2 { margin: 0; font-family: var(--font-display); font-size: 32px; font-weight: 600; }
.detail-head .detail-roaster { opacity: .7; margin: 6px 0 18px; font-size: 15px; }
.detail-grid { display: flex; flex-wrap: wrap; gap: 30px; }
.detail-grid .stat .stat-num { color: var(--paper); font-size: 26px; }
.detail-grid .stat .stat-num.accent { color: var(--gold); }
.detail-grid .stat .stat-label { color: rgba(239, 230, 214, .65); }
.detail-section-title {
  font-family: var(--font-display); font-size: 21px; font-weight: 600; margin: 0 0 16px;
  display: flex; align-items: center; gap: 12px;
}
.detail-section-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- 弹窗（dialog） ---------- */
.dialog {
  width: min(680px, 94vw); border: none; border-radius: var(--radius-xl); padding: 0;
  background: var(--paper-2); color: var(--ink); box-shadow: var(--shadow);
  /* 动画由 JS 通过 CSS 自定义属性或类名驱动；这里做兜底 */
  transition: opacity 0.3s var(--ease-out), transform 0.3s var(--ease-spring);
}
/* 关闭状态（JS 在 close 前动态添加） */
.dialog.closing {
  opacity: 0; transform: scale(0.94);
  transition: opacity 0.18s ease-in, transform 0.18s ease-in;
}
.dialog::backdrop {
  background: rgba(42, 28, 18, .45); backdrop-filter: blur(3px);
  transition: opacity 0.25s;
}
/* 原生 dialog 不支持 backdrop 过渡，靠 JS 手动加类 */
.dialog.backdrop-fading .dialog::backdrop { opacity: 0; }

.form { padding: 28px 32px 28px; }
.dialog-title { margin: 0 0 22px; font-family: var(--font-display); font-size: 24px; font-weight: 600; }

/* 表单分组 */
.form-section {
  border: none; padding: 0; margin: 0 0 20px;
}
.form-section legend {
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 500;
  letter-spacing: .14em; text-transform: uppercase; color: var(--ink-soft);
  margin-bottom: 12px; padding-bottom: 6px; width: 100%;
  border-bottom: 1px solid var(--hairline);
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.field em { color: var(--accent); font-style: normal; }
.field em.hint { color: var(--ink-soft); font-weight: 400; font-size: 11px; }

.field input, .field select, .field textarea {
  font-family: var(--font-body); font-size: 15px; color: var(--ink);
  padding: 10px 12px; border-radius: var(--radius-sm); border: 1.5px solid var(--line);
  background: var(--paper); width: 100%;
  transition: border-color 0.2s, box-shadow 0.25s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(184, 92, 56, .12);
}
.field textarea { resize: vertical; }
.field input[type="number"], .field input[name="totalTime"] { font-family: var(--font-mono); }

/* 必填字段抖动 */
@keyframes field-shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-3px); }
  40%      { transform: translateX(3px); }
  60%      { transform: translateX(-2px); }
  80%      { transform: translateX(2px); }
}
.field.shake { animation: field-shake 0.4s ease; }
.field.shake input, .field.shake select { border-color: var(--warn); }

/* 自定义评分滑块 */
.rating-field input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 8px; border-radius: 4px;
  background: linear-gradient(to right, var(--accent), var(--gold) 80%, var(--line) 80%);
  padding: 0; border: none;
  cursor: pointer;
}
.rating-field input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--ink); border: 3px solid var(--paper);
  cursor: pointer; box-shadow: 0 2px 8px rgba(42,28,18,.2);
  transition: transform 0.2s var(--ease-spring), box-shadow 0.2s;
}
.rating-field input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }
.rating-field input[type="range"]::-webkit-slider-thumb:active { transform: scale(1.08); }
.rating-field input[type="range"]::-moz-range-thumb {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--ink); border: 3px solid var(--paper);
  cursor: pointer; box-shadow: 0 2px 8px rgba(42,28,18,.2);
}

.rating-output {
  font-family: var(--font-mono); font-weight: 600; color: var(--accent); font-size: 15px;
  transition: transform 0.2s var(--ease-spring), color 0.2s;
}
.rating-output.pulse { transform: scale(1.18); color: var(--gold); }

/* 实时反馈区 */
.live-readout {
  display: flex; gap: 16px; margin: 4px 0 20px;
}
.live-readout .readout {
  flex: 1; text-align: center; background: rgba(184, 92, 56, .08);
  border: 1px solid rgba(184, 92, 56, .18); border-radius: var(--radius-md); padding: 12px;
  transition: background 0.2s, border-color 0.2s;
}
.readout-label {
  display: block; font-family: var(--font-mono); font-size: 10px; font-weight: 500;
  letter-spacing: .14em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 2px;
}
.readout-value {
  font-family: var(--font-mono); font-size: 24px; font-weight: 600; color: var(--accent-dk);
  transition: transform 0.2s var(--ease-spring), color 0.2s;
}
.readout-value.pulse { transform: scale(1.12); color: var(--accent); }

.dialog-actions {
  display: flex; justify-content: flex-end; gap: 10px;
  margin-top: 26px; padding-top: 18px;
  border-top: 1px solid var(--hairline);
}

/* ---------- 内联删除确认 ---------- */
.confirm-bar {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 12px 16px; margin-top: 14px;
  background: rgba(184, 92, 56, .06); border: 1px solid rgba(184, 92, 56, .25);
  border-radius: var(--radius-md);
  animation: fade-up 0.25s var(--ease-out) both;
}
.confirm-bar .confirm-text { font-size: 13px; color: var(--accent-dk); font-weight: 500; margin-right: auto; }
.confirm-bar button {
  font-size: 12.5px; font-weight: 600; padding: 5px 14px; border-radius: 999px;
  cursor: pointer; border: 1.5px solid;
}
.confirm-bar .confirm-yes {
  background: var(--accent); border-color: var(--accent); color: #fff;
  transition: background 0.2s, transform 0.15s;
}
.confirm-bar .confirm-yes:hover { background: var(--accent-dk); }
.confirm-bar .confirm-no {
  background: transparent; border-color: var(--line); color: var(--ink-soft);
  transition: border-color 0.2s, color 0.2s;
}
.confirm-bar .confirm-no:hover { border-color: var(--ink); color: var(--ink); }

/* 删除退出动画 */
@keyframes card-out {
  to { opacity: 0; transform: scale(0.92) translateY(-8px); }
}
.card-removing { animation: card-out 0.25s ease-in forwards; pointer-events: none; }

/* ---------- Toast 通知 ---------- */
.toast-container {
  position: fixed; top: 16px; right: 16px; z-index: 100;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  font-family: var(--font-body); font-size: 14px; font-weight: 600;
  padding: 12px 18px; border-radius: var(--radius-md);
  background: var(--ink); color: var(--paper);
  box-shadow: var(--shadow-md);
  pointer-events: auto; cursor: default;
  animation: toast-in 0.35s var(--ease-spring) both;
  transition: opacity 0.3s ease, transform 0.3s var(--ease-spring);
  max-width: 360px;
}
.toast.success { border-left: 3px solid var(--good); }
.toast.warn    { border-left: 3px solid var(--gold); }
.toast.error   { border-left: 3px solid var(--warn); }
.toast.out     { opacity: 0; transform: translateX(40px); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(60px) scale(0.9); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

/* ---------- 评分关联分析 ---------- */
.analysis-block {
  background: var(--paper-2); border: 1px solid var(--hairline); border-radius: var(--radius-xl);
  padding: 28px 32px; margin-bottom: 22px; box-shadow: var(--shadow-sm);
}
.analysis-block h3 {
  margin: 0 0 4px; font-family: var(--font-display); font-size: 20px; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}
.analysis-block .block-sub { margin: 0 0 16px; font-size: 13px; color: var(--ink-soft); }

.notice {
  display: flex; align-items: center; gap: 10px;
  border-radius: var(--radius-md); padding: 14px 18px; margin-bottom: 20px; font-size: 14px;
}
.notice.warn { background: rgba(184, 92, 56, .10); border: 1px solid rgba(184, 92, 56, .3); color: var(--accent-dk); }

.recipe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.recipe-item { border: 1px dashed var(--line); border-radius: var(--radius-md); padding: 14px 16px; }
.recipe-item .ri-label {
  font-family: var(--font-mono); font-size: 10px; font-weight: 500;
  letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft);
}
.recipe-item .ri-value { font-family: var(--font-mono); font-size: 19px; font-weight: 600; color: var(--ink); margin-top: 4px; }
.recipe-item .ri-range { font-family: var(--font-mono); font-size: 12px; color: var(--ink-soft); margin-top: 2px; }

.suggest-card {
  background: var(--ink); color: var(--paper); border-radius: var(--radius-lg);
  padding: 24px 28px; margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.suggest-card h3 { margin: 0 0 12px; font-family: var(--font-display); font-size: 20px; font-weight: 600; }
.suggest-line { font-size: 16px; line-height: 1.9; }
.suggest-line b { font-family: var(--font-mono); color: var(--gold); font-weight: 600; padding: 0 2px; }

.compare-row { display: grid; grid-template-columns: 120px 1fr 64px; align-items: center; gap: 12px; margin-bottom: 10px; }
.compare-row .cr-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compare-row .cr-bar-wrap { background: var(--line); border-radius: 999px; height: 12px; overflow: hidden; }
.compare-row .cr-bar { height: 100%; background: linear-gradient(90deg, var(--gold), var(--accent)); border-radius: 999px; transition: width 0.6s var(--ease-out); }
.compare-row .cr-val { font-family: var(--font-mono); font-size: 14px; font-weight: 600; text-align: right; }
.compare-row .cr-count { font-size: 11px; color: var(--ink-soft); font-weight: 400; }
.compare-group + .compare-group { margin-top: 22px; }
.compare-group > h4 { margin: 0 0 12px; font-size: 14px; color: var(--ink-soft); font-weight: 600; }

/* ---------- 味道复选框 + 建议 ---------- */
.taste-field {
  border: 1.5px solid var(--line); border-radius: var(--radius-md);
  padding: 14px 16px 16px; margin: 4px 0 4px;
  transition: border-color 0.2s;
}
.taste-field:hover { border-color: rgba(184,92,56,.2); }
.taste-field legend { padding: 0 6px; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.taste-options { display: flex; flex-wrap: wrap; gap: 8px; }
.taste-check {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  font-size: 13.5px; padding: 6px 14px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--paper); user-select: none;
  transition: border-color 0.15s, background 0.15s, color 0.15s, transform 0.15s var(--ease-spring);
}
.taste-check:hover { border-color: var(--accent); transform: translateY(-1px); }
.taste-check input { accent-color: var(--accent); margin: 0; }
.taste-check:has(input:checked) { background: rgba(184, 92, 56, .12); border-color: var(--accent); color: var(--accent-dk); font-weight: 600; }

.taste-advice:not(:empty) {
  margin-top: 12px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: rgba(192, 138, 62, .12); border: 1px dashed rgba(192, 138, 62, .4);
  animation: fade-up 0.3s var(--ease-out) both;
}
.taste-advice .ba-title { font-weight: 700; font-size: 13.5px; margin-bottom: 6px; }
.taste-advice .ba-line { font-size: 13.5px; line-height: 1.7; color: var(--ink); }
.taste-advice .ba-line b { font-family: var(--font-body); color: var(--accent-dk); }
.taste-advice .ba-empty { color: var(--ink-soft); font-style: italic; }

.taste-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.taste-chip {
  font-size: 11.5px; padding: 2px 9px; border-radius: 999px;
  background: rgba(192, 138, 62, .15); color: var(--accent-dk); border: 1px solid rgba(192, 138, 62, .35);
}
.brew-advice {
  margin-top: 10px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: rgba(192, 138, 62, .10); border-left: 3px solid var(--gold);
}
.brew-advice .ba-title { font-size: 12.5px; font-weight: 700; margin-bottom: 4px; }
.brew-advice .ba-line { font-size: 13px; line-height: 1.65; color: var(--ink-soft); }
.brew-advice .ba-line b { color: var(--accent-dk); font-weight: 600; }

/* ---------- 最佳配方 + 调试轨迹 ---------- */
.best-recipe {
  background: linear-gradient(135deg, rgba(192, 138, 62, .14), rgba(184, 92, 56, .08)), var(--paper-2);
  border: 1.5px solid rgba(192, 138, 62, .45); border-radius: var(--radius-lg);
  padding: 24px 28px; margin-bottom: 28px;
}
.best-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.best-head h3 { margin: 0; font-family: var(--font-display); font-size: 21px; font-weight: 600; }
.best-rating { font-family: var(--font-mono); font-size: 30px; font-weight: 600; color: var(--accent); }
.best-rating small { font-size: 14px; opacity: .6; }
.best-sub { margin: 6px 0 18px; font-size: 13px; color: var(--ink-soft); }
.br-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; margin-bottom: 20px; }
.br-item {
  border: 1px dashed var(--line); border-radius: var(--radius-sm); padding: 12px 14px;
  background: rgba(247, 240, 227, .5);
}
.br-item .br-k {
  font-family: var(--font-mono); font-size: 10px; font-weight: 500;
  letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft);
}
.br-item .br-v { font-family: var(--font-mono); font-size: 16px; font-weight: 600; color: var(--ink); margin-top: 3px; word-break: break-word; }

.trajectory { position: relative; margin: 0 0 28px; padding-left: 8px; }
.traj-point {
  position: relative; display: grid; grid-template-columns: 36px 1fr; gap: 16px;
  align-items: start; padding: 0 0 20px;
}
.traj-point:not(:last-child)::before {
  content: ""; position: absolute; left: 17px; top: 32px; bottom: -4px;
  width: 2px; background: var(--line);
}
.traj-dot {
  width: 36px; height: 36px; border-radius: 50%; flex: none; z-index: 1;
  display: grid; place-items: center;
  font-family: var(--font-mono); font-size: 13px; font-weight: 600;
  background: var(--ink); color: var(--paper);
  transition: transform 0.25s var(--ease-spring);
}
.traj-point:hover .traj-dot { transform: scale(1.12); }
.traj-body { padding-top: 4px; }
.traj-top { display: flex; align-items: center; gap: 10px; }
.traj-date { font-family: var(--font-mono); font-size: 13px; color: var(--ink-soft); }
.traj-meta { margin-top: 4px; font-size: 13px; color: var(--ink-soft); }

/* ---------- 页脚 ---------- */
.site-footer {
  max-width: 1120px; margin: 0 auto; padding: 28px 28px 48px;
  color: var(--ink-soft); font-size: 11px;
  letter-spacing: .08em; text-transform: uppercase; text-align: center;
}

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

/* ---------- 响应式：平板 ---------- */
@media (max-width: 900px) {
  .site-header { padding: 28px 20px 10px; }
  .content { padding: 32px 20px 64px; max-width: 100%; }
  .tabs { padding: 0 20px; max-width: 100%; }
  .site-footer { padding: 24px 20px 40px; }
  .dialog { width: min(90vw, 680px); }
  .beans-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
  .brew-card { grid-template-columns: 90px 1fr auto; gap: 18px; padding: 20px 22px; }
  .brew-ratio { padding-right: 14px; }
}

/* ---------- 响应式：手机 ---------- */
@media (max-width: 620px) {
  /* ---- 基础 ---- */
  .content { padding: 24px 14px 48px; }
  .site-footer { padding: 20px 14px 36px; font-size: 10px; letter-spacing: .04em; }

  /* ---- 顶部：堆叠布局，每块独立不重叠 ---- */
  .site-header {
    flex-direction: column; align-items: stretch; gap: 10px;
    padding: 16px 14px 10px; flex-wrap: nowrap; /* 禁止换行重叠 */
  }
  /* 品牌区 */
  .brand { gap: 10px; align-items: center; overflow: hidden; }
  .brand-mark { width: 40px; height: 40px; font-size: 20px; flex: none; }
  .brand-text { min-width: 0; overflow: hidden; }
  .brand-text h1 { font-size: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .tagline { font-size: 11px; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* 工具栏：独立一行，按钮不换行 */
  .toolbar {
    width: 100%; display: flex; align-items: center; gap: 6px;
    flex-wrap: nowrap; /* 防止按钮换行重叠 */
  }
  .toolbar .btn {
    font-size: 11px; padding: 6px 11px; white-space: nowrap;
    flex-shrink: 0; /* 按钮不压缩 */
  }

  /* 同步指示器：手机端紧凑 */
  .sync-indicator {
    font-size: 10px; padding: 5px 10px; max-width: none; flex-shrink: 0;
  }
  .sync-indicator .sync-dot { width: 6px; height: 6px; }

  /* ---- 标签页：均分宽度，防溢出 ---- */
  .tabs {
    padding: 0 4px; gap: 0; margin-top: 12px;
    justify-content: space-around; overflow: hidden;
  }
  .tab { padding: 10px 4px; font-size: 14px; flex: 1; justify-content: center; min-width: 0; }
  .tab .tab-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .tab .tab-count { font-size: 10px; padding: 1px 5px; flex-shrink: 0; }

  /* 全局防溢出 */
  .content, .beans-grid, .brews-list { overflow: hidden; }
  .bean-card, .brew-card { overflow: hidden; }
  .chips { overflow: hidden; flex-wrap: wrap; }
  .chip { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* ---- 豆子卡片 ---- */
  .beans-grid { grid-template-columns: 1fr; gap: 14px; }
  .bean-card { padding: 20px 22px; border-radius: var(--radius-lg); }
  .bean-card .bean-name { font-size: 20px; }
  .bean-card .bean-roaster { font-size: 12px; margin-bottom: 12px; }
  .chips { margin-bottom: 14px; gap: 4px; }
  .chip { font-size: 10px; padding: 2px 8px; }
  .bean-stats { gap: 18px; padding-top: 14px; }
  .stat .stat-num { font-size: 22px; }
  .bean-usage .usage-text { font-size: 10px; }

  /* ---- 冲煮卡片：时间线式 ---- */
  .brew-card {
    grid-template-columns: 1fr; gap: 12px; padding: 18px 18px;
    border-radius: var(--radius-md);
  }
  .brew-ratio {
    display: flex; align-items: baseline; gap: 8px; text-align: left;
    border-right: none; border-bottom: 1px dashed var(--line);
    padding: 0 0 10px;
  }
  .brew-ratio .ratio-num { font-size: 20px; }
  .brew-side {
    flex-direction: row; align-items: center; justify-content: space-between;
  }
  .brew-meta { gap: 4px 14px; font-size: 10px; }
  .brew-meta b { font-size: 12px; }
  .brew-notes { font-size: 12.5px; }
  .brew-date { font-size: 11px; }
  .rating-badge { padding: 3px 8px; }
  .rating-badge .r-num { font-size: 15px; }

  .row-actions { gap: 4px; }
  .btn-mini { font-size: 11px; padding: 4px 10px; }

  /* ---- 详情页 ---- */
  .detail-head { padding: 22px 18px; border-radius: var(--radius-lg); }
  .detail-head h2 { font-size: 24px; }
  .detail-head .detail-roaster { font-size: 13px; margin: 4px 0 14px; }
  .detail-grid { gap: 16px; }
  .detail-grid .stat .stat-num { font-size: 20px; }
  .detail-section-title { font-size: 18px; margin-bottom: 12px; }

  /* ---- 弹窗：接近全屏 ---- */
  .dialog {
    width: 98vw; max-height: 96vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    margin: auto 0 0; /* 底部对齐，像 iOS 抽屉 */
  }
  .form { padding: 20px 18px 22px; }
  .dialog-title { font-size: 20px; margin-bottom: 16px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; gap: 10px; margin-bottom: 10px; }

  .field > span { font-size: 12px; }
  .field input, .field select, .field textarea {
    font-size: 16px; /* 防 iOS 缩放 */ padding: 10px 12px;
  }

  /* 弹窗按钮区 */
  .dialog-actions { margin-top: 20px; padding-top: 14px; gap: 8px; }
  .dialog-actions .btn { flex: 1; text-align: center; font-size: 15px; padding: 12px; }

  /* 实时反馈区 */
  .live-readout { gap: 8px; margin-bottom: 14px; }
  .live-readout .readout { padding: 8px; }
  .readout-value { font-size: 20px; }

  /* 评分滑块 */
  .rating-field input[type="range"] { height: 6px; }
  .rating-field input[type="range"]::-webkit-slider-thumb { width: 30px; height: 30px; }
  .rating-output { font-size: 15px; }

  /* 味道复选框 */
  .taste-field { padding: 10px 10px 12px; }
  .taste-options { gap: 6px; }
  .taste-check { font-size: 12px; padding: 5px 10px; }

  /* ---- 分析页 ---- */
  .analysis-block { padding: 18px 16px; border-radius: var(--radius-lg); }
  .analysis-block h3 { font-size: 17px; }
  .recipe-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
  .recipe-item { padding: 10px 12px; }
  .recipe-item .ri-value { font-size: 16px; }
  .compare-row { grid-template-columns: 90px 1fr 50px; gap: 8px; }

  /* ---- 空状态 ---- */
  .empty { padding: 40px 16px; }
  .empty .empty-emoji { font-size: 32px; }
  .empty p { font-size: 16px; }

  /* ---- 筛选栏 ---- */
  .filter-bar { gap: 10px; }
  .field-inline select { font-size: 13px; padding: 6px 10px; }

  /* ---- Toast：底部弹出 ---- */
  .toast-container { top: auto; bottom: 16px; right: 10px; left: 10px; }
  .toast { max-width: none; text-align: center; font-size: 13px; }

  /* ---- 内联确认条 ---- */
  .confirm-bar { flex-wrap: wrap; gap: 6px; }
  .confirm-bar .confirm-text { width: 100%; text-align: center; }

  /* ---- 最佳配方 ---- */
  .best-recipe { padding: 18px 16px; }
  .best-head h3 { font-size: 18px; }
  .best-rating { font-size: 24px; }
  .br-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
  .br-item { padding: 8px 10px; }
  .br-item .br-v { font-size: 14px; }

  /* ---- 调试轨迹 ---- */
  .traj-point { grid-template-columns: 28px 1fr; gap: 10px; padding-bottom: 14px; }
  .traj-dot { width: 28px; height: 28px; font-size: 11px; }
  .traj-point:not(:last-child)::before { left: 13px; top: 28px; }

  /* ---- 页脚 ---- */
  .site-footer { text-transform: none; letter-spacing: .02em; line-height: 1.6; }

  /* ---- 视图切换动画 ---- */
  @keyframes fade-up { from { opacity: 0; transform: translateY(8px); } }
}

/* ---------- 小屏手机（< 400px） ---------- */
@media (max-width: 400px) {
  .brand-mark { width: 36px; height: 36px; font-size: 18px; }
  .brand-text h1 { font-size: 21px; }
  .tab { font-size: 13px; padding: 8px 4px; }
  .btn { font-size: 11px; padding: 6px 10px; }
  .bean-card { padding: 16px 18px; }
  .brew-card { padding: 14px 14px; }
  .detail-head { padding: 18px 14px; }
  .dialog-actions .btn { font-size: 14px; padding: 10px; }
}
