:root {
  --bg: #F5F3EF;
  --bg-warm: #EDE8E0;
  --surface: #FFFFFF;
  --ink: #1A1715;
  --ink-2: #433B36;
  --muted: #7F756D;
  --border: #E8E2D9;
  --primary: #C8332B;
  --primary-hover: #A92720;
  --primary-soft: #FDF1F0;
  --gold: #C2822A;
  --gold-light: #F3D19C;
  --gold-soft: #FDF6EB;
  --green: #22704A;
  --green-soft: #ECF7F1;
  --shadow-xs: 0 1px 3px rgba(26, 23, 21, 0.05);
  --shadow-sm: 0 6px 20px rgba(26, 23, 21, 0.07);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body {
  height: 100%;
  background: #EBE6DE;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
button, input, select, textarea { font-family: inherit; }
button { cursor: pointer; }

.app-shell {
  max-width: 460px;
  min-height: 100%;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  box-shadow: 0 0 40px rgba(26,23,21,0.08);
  padding-bottom: calc(130px + env(safe-area-inset-bottom));
}

/* 顶部吸顶栏 */
.top-bar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255,255,255,0.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid #EFECE6;
  padding: 11px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.brand-row { display: flex; align-items: center; gap: 8px; }
.brand-badge {
  width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(135deg, #D93B32, #991F18);
  color: #FFF; font-size: 12px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.brand-name { font-size: 15.5px; font-weight: 800; color: var(--ink); }
.share-btn {
  border: 1px solid var(--border); background: #FAF8F5; color: var(--ink-2);
  border-radius: 99px; padding: 5px 11px; font-size: 11.5px; font-weight: 700;
  display: inline-flex; align-items: center; gap: 4px;
}
.share-btn:active { background: var(--bg-warm); }

/* 通用卡片与按钮 */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  box-shadow: var(--shadow-xs);
}
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 700;
}
.tag-red { background: var(--primary-soft); color: var(--primary); }
.tag-green { background: var(--green-soft); color: var(--green); }
.tag-gold { background: var(--gold-soft); color: var(--gold); }
.tag-ink { background: var(--bg-warm); color: var(--ink-2); }

.btn {
  border: none; border-radius: 11px; padding: 10px 14px;
  font-size: 13.5px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: transform 0.1s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: #FFF; }
.btn-outline { background: #FFF; color: var(--ink); border: 1px solid var(--border); }
.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: 8px; }

/* 批次鎏金黑卡 */
.hero-card {
  margin: 10px 12px;
  background: linear-gradient(135deg, #211D1B 0%, #312722 60%, #4A241E 100%);
  color: #FFF; border-radius: 18px; padding: 14px 15px;
  box-shadow: 0 10px 24px rgba(33,29,27,0.16);
}
.hero-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.batch-select {
  background: rgba(243,209,156,0.16); color: var(--gold-light);
  border: 1px solid rgba(243,209,156,0.3); border-radius: 99px;
  padding: 3px 10px; font-size: 11px; font-weight: 700; outline: none;
}
.status-pill {
  font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 99px;
  background: rgba(255,255,255,0.14); color: #F5DFC0; white-space: nowrap;
}
.hero-title { font-size: 16px; font-weight: 800; margin-bottom: 10px; }
.progress-meta { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 6px; }
.progress-track {
  height: 8px; background: rgba(255,255,255,0.16);
  border-radius: 99px; overflow: hidden; position: relative;
}
.progress-fill {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, #E8A64B 0%, #E24A3F 100%);
  transition: width 0.45s cubic-bezier(.22,1,.36,1);
}
.progress-fill.ready { background: linear-gradient(90deg, #3FC27B 0%, #248F56 100%); }
.threshold-mark { position: absolute; top: 0; bottom: 0; width: 2px; background: rgba(255,255,255,0.9); }
.ticker-row {
  margin-top: 9px; padding-top: 8px; border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 11.5px; color: #DFD5CE; display: flex; align-items: center; gap: 6px;
}

/* 模式切换 */
.mode-switch {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px;
  margin: 0 12px 10px; background: #EAE5DD; padding: 4px; border-radius: 13px;
}
.mode-btn {
  border: none; background: transparent; padding: 8px 4px; border-radius: 10px;
  font-size: 13px; font-weight: 700; color: var(--ink-2);
}
.mode-btn.active { background: #FFF; color: var(--ink); box-shadow: 0 2px 8px rgba(26,23,21,0.09); }
.mode-sub { display: block; font-size: 10.5px; font-weight: 500; color: var(--muted); margin-top: 1px; }
.mode-btn.active .mode-sub { color: var(--primary); font-weight: 600; }

/* 黑猪交互画布 */
.pig-stage-card {
  margin: 0 12px 10px; background: #FFF; border: 1px solid var(--border);
  border-radius: 18px; padding: 13px 12px 12px; box-shadow: var(--shadow-xs);
}
.pig-stage-head {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  margin-bottom: 6px;
}
.pig-stage-title { font-size: 13px; font-weight: 800; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pig-legend { display: flex; gap: 7px; font-size: 10.5px; color: var(--muted); white-space: nowrap; flex-shrink: 0; }
.legend-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 3px; vertical-align: middle; }

.pig-art-box {
  position: relative; width: 100%; border-radius: 12px; overflow: hidden;
  background: #FFF; margin-bottom: 10px;
}
.pig-art-img { width: 100%; display: block; user-select: none; pointer-events: none; }
.pig-overlay-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.cut-zone { fill: rgba(200,51,43,0); stroke: transparent; stroke-width: 4; cursor: pointer; transition: fill 0.18s, stroke 0.18s; }
.cut-zone.active { fill: rgba(200,51,43,0.34); stroke: #FFD58A; stroke-width: 5.5; }
.cut-zone.soldout-zone { fill: rgba(255,255,255,0.45); }
.cut-zone.soldout-zone.active { fill: rgba(140,130,122,0.45); stroke: #FFF; stroke-width: 5; }
.cut-zone.mode-half-lit { fill: rgba(194,130,42,0.28); stroke: rgba(255,224,166,0.85); stroke-width: 4; }
.cut-zone.mode-whole-lit { fill: rgba(200,51,43,0.22); stroke: rgba(255,213,138,0.9); stroke-width: 4.5; }

.pin-group { cursor: pointer; }
.pin-pulse { fill: none; stroke: #FFD58A; stroke-width: 4; opacity: 0; transform-box: fill-box; transform-origin: center; }
.pin-group.is-selected .pin-pulse { animation: ringPing 1.6s cubic-bezier(0,0,0.2,1) infinite; }
@keyframes ringPing { 0% { transform: scale(1); opacity: 0.9; } 100% { transform: scale(2.4); opacity: 0; } }
.pin-outer { fill: rgba(255,255,255,0.93); filter: drop-shadow(0 2px 4px rgba(0,0,0,0.35)); }
.pin-core-ok { fill: #268957; }
.pin-core-low { fill: #DF861E; }
.pin-core-out { fill: #9D948D; }
.pin-core-sel { fill: #D93025; }
.active-callout { pointer-events: none; }

/* 11部位芯片网格 */
.part-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.part-chip {
  border: 1.5px solid #EAE4DC; background: #FAF8F5; border-radius: 10px;
  padding: 7px 4px; text-align: center; cursor: pointer; position: relative;
}
.part-chip.selected { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 3px 10px rgba(200,51,43,0.14); }
.part-chip.soldout { opacity: 0.56; background: #F2EFEA; }
.part-chip-name { font-size: 12px; font-weight: 700; color: var(--ink); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.part-chip.selected .part-chip-name { color: var(--primary); }
.part-chip-rem { font-size: 10px; color: var(--muted); display: block; margin-top: 1px; }
.part-chip-dot { position: absolute; top: 5px; right: 5px; width: 5px; height: 5px; border-radius: 50%; }

/* 详情卡 */
.detail-card { margin: 0 12px 12px; background: #FFF; border: 1px solid var(--border); border-radius: 18px; padding: 15px; box-shadow: var(--shadow-xs); }
.part-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.part-name { font-size: 18px; font-weight: 800; }
.part-alias { font-size: 12px; color: var(--muted); margin-top: 2px; }
.part-price { font-size: 22px; font-weight: 800; color: var(--primary); line-height: 1; text-align: right; }
.part-price small { font-size: 11px; font-weight: 500; color: var(--muted); }
.meat-specs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  background: #FAF8F5; border-radius: 11px; padding: 9px 11px; margin-bottom: 10px;
}
.spec-label { font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; margin-bottom: 4px; }
.spec-bar { height: 5px; border-radius: 99px; background: #E6DFD6; overflow: hidden; display: flex; }
.spec-lean { background: #C8332B; height: 100%; }
.spec-fat { background: #E9BA73; height: 100%; }
.cook-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 12px; align-items: center; }
.cook-tag { font-size: 11.5px; background: var(--green-soft); color: var(--green); padding: 3px 8px; border-radius: 6px; font-weight: 600; }
.qty-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: #FFF; }
.stepper button { width: 36px; height: 34px; border: none; background: #FAF8F5; font-size: 17px; font-weight: 700; color: var(--ink); }
.stepper span { min-width: 56px; text-align: center; font-weight: 800; font-size: 14px; }
.quick-weights { display: flex; gap: 6px; margin-bottom: 12px; }
.qw-btn { flex: 1; border: 1px solid var(--border); background: #FFF; border-radius: 8px; padding: 6px; font-size: 12px; color: var(--ink-2); font-weight: 600; }
.qw-btn.active { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }

/* 底部悬浮预定篮 + TabBar */
.cart-bar {
  position: fixed; bottom: calc(64px + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%);
  width: calc(100% - 24px); max-width: 436px;
  background: #1B1816; color: #FFF; border-radius: 99px;
  padding: 6px 6px 6px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  box-shadow: 0 10px 28px rgba(26,23,21,0.28); z-index: 25;
}
.cart-info { font-size: 12.5px; cursor: pointer; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cart-info strong { font-size: 16px; color: var(--gold-light); margin-right: 4px; }
.cart-btn { background: var(--primary); color: #FFF; border: none; border-radius: 99px; padding: 9px 16px; font-size: 13px; font-weight: 700; flex-shrink: 0; }

.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 460px;
  background: rgba(255,255,255,0.97); backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  display: grid; grid-template-columns: repeat(3, 1fr);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
  z-index: 30;
}
.tab-item {
  border: none; background: transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; color: var(--muted); font-weight: 600;
}
.tab-item.active { color: var(--primary); }

/* 黑猪风采 */
.page-pad { padding: 12px; }
.story-filter-bar { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 10px; }
.story-filter-pill { border: 1px solid var(--border); background: #FFF; color: var(--ink-2); border-radius: 99px; padding: 6px 13px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.story-filter-pill.active { background: var(--ink); color: #FFF; border-color: var(--ink); }
.story-card { background: #FFF; border: 1px solid var(--border); border-radius: 16px; overflow: hidden; margin-bottom: 12px; box-shadow: var(--shadow-xs); cursor: pointer; }
.story-cover { height: 160px; position: relative; display: flex; flex-direction: column; justify-content: space-between; padding: 12px; color: #FFF; background-size: cover; background-position: center; }
.story-cover-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.story-cover-scrim { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0.12) 45%, rgba(0,0,0,0.58) 100%); }
.story-cover > * { position: relative; z-index: 2; }
.story-play-circle {
  position: absolute !important; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 48px; height: 48px; border-radius: 50%;
  background: rgba(20,16,14,0.68); border: 2px solid rgba(255,255,255,0.88);
  display: flex; align-items: center; justify-content: center;
}
.story-duration { position: absolute !important; right: 10px; bottom: 10px; background: rgba(20,16,14,0.74); color: #FFF; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 6px; }
.story-body { padding: 12px 14px; }
.story-title { font-size: 15px; font-weight: 800; margin-bottom: 4px; line-height: 1.38; }
.story-summary { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.story-foot { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); }

/* 我的个人中心 */
.mine-header {
  background: linear-gradient(135deg, #201C1A 0%, #372821 100%);
  color: #FFF; border-radius: 18px; padding: 16px; margin-bottom: 12px;
}
.mine-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: linear-gradient(135deg, #D93B32, #E6A23C);
  display: flex; align-items: center; justify-content: center;
  font-size: 19px; font-weight: 800; color: #FFF; flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.28);
}
.mine-subtabs {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px;
  background: #EAE5DD; padding: 4px; border-radius: 12px; margin-bottom: 12px;
}
.mine-subtab { border: none; background: transparent; padding: 8px 4px; border-radius: 9px; font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
.mine-subtab.active { background: #FFF; color: var(--primary); box-shadow: 0 2px 6px rgba(26,23,21,0.08); }
.addr-card { background: #FFF; border: 1.5px solid var(--border); border-radius: 14px; padding: 12px; margin-bottom: 10px; }
.addr-card.is-default { border-color: #E2A9A2; background: #FFFCFB; }
.addr-quick-strip { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 10px; padding-bottom: 2px; }
.addr-quick-chip { border: 1px solid var(--border); background: #FAF8F5; border-radius: 9px; padding: 6px 10px; font-size: 11.5px; color: var(--ink-2); white-space: nowrap; flex-shrink: 0; }
.addr-quick-chip.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 700; }

/* 底部抽屉与表单 */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(20,16,14,0.55);
  z-index: 60; display: none; align-items: flex-end; justify-content: center;
}
.sheet-backdrop.open { display: flex; }
.sheet {
  width: 100%; max-width: 460px; max-height: 90vh; background: #FFF;
  border-top-left-radius: 22px; border-top-right-radius: 22px;
  padding: 16px 16px calc(22px + env(safe-area-inset-bottom));
  overflow-y: auto; animation: slideUp 0.2s ease;
}
@keyframes slideUp { from { transform: translateY(36px); opacity: 0.4; } to { transform: translateY(0); opacity: 1; } }
.form-group { margin-bottom: 10px; }
.form-label { display: block; font-size: 12px; font-weight: 700; color: var(--ink-2); margin-bottom: 4px; }
.form-input, .form-select {
  width: 100%; border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 11px; font-size: 14px; background: #FAF8F5; color: var(--ink);
}
.form-input:focus, .form-select:focus { outline: none; border-color: var(--primary); background: #FFF; }
.remark-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.remark-chip { border: 1px solid var(--border); background: #FFF; border-radius: 99px; padding: 4px 10px; font-size: 11.5px; color: var(--ink-2); }

.toast {
  position: fixed; top: 72px; left: 50%; transform: translateX(-50%) translateY(-10px);
  background: rgba(26,23,21,0.92); color: #FFF; padding: 9px 16px; border-radius: 99px;
  font-size: 13px; font-weight: 600; opacity: 0; pointer-events: none;
  transition: all 0.22s ease; z-index: 120; max-width: 88vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
