/* ============================================================
   涂选家 V3 — 移动端优先样式表
   设计原则：手机浏览器为主，兼顾 PC 端
   流程：选产品 → 选场景 → 选颜色 → 输面积 → 看结果
   ============================================================ */

*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }

:root {
  --primary:       #2563EB;
  --primary-dark:  #1D4ED8;
  --primary-light: #DBEAFE;
  --primary-hover: #1E40AF;
  --accent:        #F59E0B;
  --accent-dark:   #D97706;
  --success:       #16A34A;
  --success-light: #DCFCE7;
  --danger:        #DC2626;
  --danger-light:  #FEE2E2;
  --bg:            #F8FAFC;
  --bg-card:       #FFFFFF;
  --bg-section:    #F1F5F9;
  --text-primary:  #0F172A;
  --text-secondary:#475569;
  --text-muted:    #94A3B8;
  --border:        #E2E8F0;
  --border-hover:  #CBD5E1;
  --shadow-sm:     0 1px 2px rgba(0,0,0,0.05);
  --shadow:        0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg:     0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
  --shadow-xl:     0 20px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.04);
  --radius-sm: 6px;  --radius: 10px;  --radius-lg: 16px;  --radius-xl: 24px;
  --transition: all 0.2s ease;
  /* safe-area 用于刘海屏/底部横条 */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html {
  scroll-behavior:smooth;
  /* 防止 iOS Safari 弹性滚动导致的背景露出 */
  overflow:hidden; height:100%;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text-primary); line-height:1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;  /* 消除点击高亮 */
  -webkit-text-size-adjust: 100%;            /* 防止横屏字体缩放 */
  overscroll-behavior-y: contain;            /* 防止过度滚动 */
  overflow-x:hidden; overflow-y:auto; height:100%;
  /* 触摸操作优化 */
  touch-action:pan-y;
}

/* ─── 顶部品牌区（移动端紧凑） ─── */
.brand-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color:#fff; position:sticky; top:0; z-index:100;
  box-shadow:var(--shadow-lg);
  /* 刘海屏适配 */
  padding-top: var(--safe-top);
}
.brand-header__inner {
  max-width:1200px; margin:0 auto;
  padding:10px 16px;
  display:flex; align-items:center; justify-content:space-between;
}
.brand-header__logo {
  display:flex; align-items:center; gap:10px;
  font-size:18px; font-weight:700; letter-spacing:0.5px;
}
.brand-header__logo-img {
  width:38px; height:38px; object-fit:contain;
  background:#fff; border-radius:var(--radius-sm);
  box-shadow:0 2px 6px rgba(0,0,0,0.15);
}
.brand-header__tagline {
  font-size:11px; opacity:0.85; font-weight:400; margin-top:1px;
}

/* ─── 步骤指示器 ─── */
.steps-bar {
  display:flex; align-items:center; justify-content:center; gap:0;
  padding:12px 12px 4px; max-width:1200px; margin:0 auto;
  /* 防止步骤条被刘海遮挡 */
}
.step-item { display:flex; align-items:center; gap:4px; }
.step-item__num {
  width:26px; height:26px; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  font-size:12px; font-weight:700;
  background:var(--bg-section); color:var(--text-muted); border:2px solid var(--border);
  transition:var(--transition); flex-shrink:0;
}
.step-item.active .step-item__num {
  background:var(--primary); color:#fff; border-color:var(--primary);
  box-shadow:0 0 0 3px var(--primary-light);
}
.step-item.completed .step-item__num { background:var(--success); color:#fff; border-color:var(--success); }
.step-item__label { font-size:11px; font-weight:500; color:var(--text-muted); white-space:nowrap; }
.step-item.active .step-item__label { color:var(--primary); font-weight:600; }
.step-item.completed .step-item__label { color:var(--text-secondary); }
.step-divider { width:16px; height:2px; background:var(--border); margin:0 2px; flex-shrink:0; }

/* ─── 容器 ─── */
.container { max-width:1200px; margin:0 auto; padding:0 16px; }

/* ─── Section ─── */
.section { padding:16px 0; }
.section--locked { opacity:0.45; pointer-events:none; }
.section--locked.unlocked { opacity:1; pointer-events:auto; }
.section__header { display:flex; align-items:center; gap:8px; margin-bottom:12px; }
.section__title { font-size:17px; font-weight:700; }
.section__title-num {
  width:24px; height:24px; border-radius:50%; background:var(--primary); color:#fff;
  font-size:12px; font-weight:700; display:inline-flex; align-items:center; justify-content:center;
}
.section__lock-hint {
  font-size:13px; color:var(--text-muted); text-align:center; padding:24px 0;
  background:var(--bg-card); border:2px dashed var(--border); border-radius:var(--radius);
}

/* ─── 产品卡片（移动端紧凑） ─── */
.product-grid {
  display:grid;
  grid-template-columns:1fr 1fr;  /* 手机端两列 */
  gap:10px;
}
.product-card {
  background:var(--bg-card); border:2px solid var(--border); border-radius:var(--radius);
  padding:12px; cursor:pointer; transition:var(--transition); position:relative; overflow:hidden;
  /* 移动端触控优化 */
  min-height:80px;
  touch-action:manipulation;
}
.product-card:active { transform:scale(0.97); }  /* 触摸反馈 */
.product-card.selected {
  border-color:var(--primary); background:var(--primary-light);
  box-shadow:0 0 0 3px rgba(37,99,235,0.15);
}
.product-card__selected-check {
  position:absolute; top:8px; left:8px; width:20px; height:20px; border-radius:50%;
  background:var(--primary); color:#fff; display:none; align-items:center; justify-content:center; font-size:12px;
}
.product-card.selected .product-card__selected-check { display:flex; }
.product-card__category { font-size:11px; color:var(--text-muted); margin-bottom:2px; }
.product-card__name {
  font-size:14px; font-weight:600; margin-bottom:4px; line-height:1.3;
  /* 长名称不溢出 */
  overflow:hidden; text-overflow:ellipsis; display:-webkit-box;
  -webkit-line-clamp:2; -webkit-box-orient:vertical;
}
.product-card__meta {
  display:flex; flex-direction:column; gap:2px;
  font-size:11px; color:var(--text-secondary); margin-top:4px;
}
.product-card__price { font-size:18px; font-weight:700; color:var(--danger); }
.product-card__price-unit { font-size:12px; font-weight:400; color:var(--text-muted); }

/* ─── 场景卡片 ─── */
.scene-grid {
  display:grid;
  grid-template-columns:1fr 1fr 1fr;  /* 手机端三列 */
  gap:8px;
}
.scene-card {
  background:var(--bg-card); border:2px solid var(--border); border-radius:var(--radius-sm);
  padding:10px 8px; cursor:pointer; transition:var(--transition); text-align:center; position:relative;
  touch-action:manipulation;
}
.scene-card:active { transform:scale(0.95); }
.scene-card.selected {
  border-color:var(--primary); background:var(--primary-light);
  box-shadow:0 0 0 3px rgba(37,99,235,0.15);
}
.scene-card__icon { font-size:24px; margin-bottom:2px; }
.scene-card__name { font-size:13px; font-weight:600; }
.scene-card__check {
  position:absolute; top:6px; right:6px; width:16px; height:16px; border-radius:50%;
  background:var(--primary); color:#fff; font-size:10px; display:none; align-items:center; justify-content:center;
}
.scene-card.selected .scene-card__check { display:flex; }

/* ─── 颜色选择器 ─── */
.color-picker {
  display:grid;
  grid-template-columns:repeat(5, 1fr);  /* 手机端5列，方便触摸 */
  gap:8px;
  justify-items:center;
}
.color-swatch {
  width:100%; cursor:pointer; transition:var(--transition);
  display:flex; flex-direction:column; align-items:center; gap:2px;
  touch-action:manipulation;
  /* 触控区域最小 44px */
  padding:4px 0;
}
.color-swatch__circle {
  width:40px; height:40px; border-radius:50%; border:3px solid var(--border);
  transition:var(--transition); position:relative;
  /* 确保触控面积 */
  min-width:40px; min-height:40px;
}
.color-swatch:active .color-swatch__circle { transform:scale(0.9); }
.color-swatch.selected .color-swatch__circle {
  border-color:var(--primary); border-width:3px;
  box-shadow:0 0 0 4px var(--primary-light);
}
.color-swatch.selected .color-swatch__circle::after {
  content:'✓'; position:absolute; top:50%; left:50%; transform:translate(-50%,-50%);
  color:#fff; font-size:16px; font-weight:700;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}
.color-swatch__name { font-size:10px; color:var(--text-secondary); text-align:center; line-height:1.2; }

/* ─── 场景+颜色效果图 ─── */
.scene-color-preview {
  margin-top:12px; display:none;
  animation: fadeInUp 0.3s ease;
}
.scene-color-preview.show { display:block; }
.scene-color-preview__label {
  font-size:13px; font-weight:600; color:var(--text-secondary); margin-bottom:8px;
}
.scene-color-preview__img-wrap {
  background:var(--bg-card); border:1px solid var(--border); border-radius:var(--radius);
  overflow:hidden;
  /* 手机端全宽显示 */
  width:100%;
}
.scene-color-preview__img-wrap img { width:100%; height:auto; display:block; }
.scene-color-preview__img-wrap svg { width:100%; height:auto; display:block; }

/* ─── 面积输入 ─── */
.area-input-box {
  background:var(--bg-card); border:1px solid var(--border); border-radius:var(--radius); padding:16px;
}
.area-input-box__label { font-size:14px; font-weight:600; display:block; margin-bottom:10px; }
.area-input-wrapper { display:flex; align-items:center; gap:8px; }
.area-input {
  flex:1; width:100%; padding:12px 12px;
  /* 字号 ≥16px 防止 iOS 自动缩放 */
  font-size:16px; font-weight:600;
  border:2px solid var(--border); border-radius:var(--radius-sm); outline:none;
  transition:var(--transition); color:var(--text-primary);
  -webkit-appearance:none;  /* 去掉 iOS 内阴影 */
  appearance:none;
  border-radius:var(--radius-sm);
}
.area-input:focus { border-color:var(--primary); box-shadow:0 0 0 3px rgba(37,99,235,0.1); }
.area-input.error { border-color:var(--danger); box-shadow:0 0 0 3px rgba(220,38,38,0.1); }
.area-input__unit { font-size:15px; font-weight:600; color:var(--text-secondary); flex-shrink:0; }
.area-input__hint { font-size:12px; color:var(--text-muted); margin-top:6px; }
.area-input__hint.error { color:var(--danger); }
.area-input__quick { display:flex; gap:6px; margin-top:10px; flex-wrap:wrap; }
.quick-btn {
  padding:6px 12px; font-size:12px; border:1px solid var(--border); border-radius:20px;
  background:var(--bg-card); color:var(--text-secondary); cursor:pointer; transition:var(--transition);
  touch-action:manipulation;
  /* 触控面积 */
  min-height:32px;
}
.quick-btn:active { background:var(--primary-light); color:var(--primary); }

/* ─── 推荐结果 ─── */
.result-section { padding:16px 0 80px; }  /* 底部留安全距离 */
.result-empty {
  background:var(--bg-card); border:2px dashed var(--border); border-radius:var(--radius);
  padding:32px 16px; text-align:center; color:var(--text-muted);
}
.result-empty__icon { font-size:40px; margin-bottom:8px; }
.result-empty__text { font-size:14px; line-height:1.8; }

.result-card {
  background:var(--bg-card); border-radius:var(--radius-lg); overflow:hidden;
  box-shadow:var(--shadow-xl); animation:fadeInUp 0.4s ease;
}
.result-card__header {
  background:linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color:#fff; padding:14px 16px;
  display:flex; align-items:center; justify-content:space-between;
}
.result-card__title { font-size:16px; font-weight:700; }
.result-card__badge {
  background:var(--accent); color:#fff; font-size:11px; font-weight:600;
  padding:3px 10px; border-radius:20px;
}
.result-card__body { padding:16px; }

/* 结果中的效果图 */
.result-scene-img {
  margin-bottom:16px; border-radius:var(--radius-sm); overflow:hidden;
  border:1px solid var(--border);
}
.result-scene-img img, .result-scene-img svg { width:100%; height:auto; display:block; }

.result-product-name { font-size:18px; font-weight:700; margin-bottom:4px; }
.result-product-desc { font-size:13px; color:var(--text-secondary); margin-bottom:16px; }
.result-color-tag {
  display:inline-flex; align-items:center; gap:6px;
  padding:4px 10px; border-radius:20px; font-size:12px;
  background:var(--bg-section); color:var(--text-secondary); margin-bottom:16px;
}
.result-color-tag__dot { width:12px; height:12px; border-radius:50%; border:1px solid var(--border); }

.result-stats {
  display:grid;
  grid-template-columns:1fr 1fr;  /* 手机端两列 */
  gap:8px; margin-bottom:16px;
}
.result-stat {
  background:var(--bg-section); border-radius:var(--radius-sm); padding:10px 12px; text-align:center;
}
.result-stat__label { font-size:11px; color:var(--text-muted); margin-bottom:4px; }
.result-stat__value { font-size:18px; font-weight:700; }
.result-stat__unit { font-size:12px; font-weight:400; color:var(--text-muted); }
.result-stat--highlight { background:var(--danger-light); }
.result-stat--highlight .result-stat__value { color:var(--danger); }

/* 计算过程 */
.calc-process {
  background:var(--bg-section); border-radius:var(--radius-sm); padding:14px; margin-bottom:16px;
}
.calc-process__title { font-size:13px; font-weight:600; color:var(--text-secondary); margin-bottom:8px; }
.calc-step {
  display:flex; align-items:flex-start; gap:8px; padding:4px 0;
  font-size:12px; color:var(--text-secondary); line-height:1.7;
}
.calc-step__num {
  width:18px; height:18px; border-radius:50%; background:var(--primary); color:#fff;
  font-size:10px; display:flex; align-items:center; justify-content:center; flex-shrink:0; margin-top:2px;
}
.calc-step__formula {
  font-family:"Consolas","Monaco",monospace; background:var(--bg-card);
  padding:2px 4px; border-radius:3px; font-size:11px; color:var(--text-primary); border:1px solid var(--border);
  /* 手机端公式可能很长，允许换行 */
  word-break:break-all;
}

/* 结果底部 */
.result-footer {
  display:flex; align-items:center; justify-content:space-between;
  padding:14px 16px; background:var(--bg-section);
  flex-wrap:wrap; gap:12px;
  /* 底部安全区域 */
  padding-bottom: calc(14px + var(--safe-bottom));
}
.result-total { display:flex; align-items:baseline; gap:4px; }
.result-total__label { font-size:13px; color:var(--text-secondary); }
.result-total__value { font-size:26px; font-weight:800; color:var(--danger); }
.btn-copy {
  background:linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color:#fff; border:none; padding:12px 16px;
  font-size:14px; font-weight:700;
  border-radius:var(--radius); cursor:pointer; transition:var(--transition);
  box-shadow:0 4px 12px rgba(245,158,11,0.3);
  display:flex; align-items:center; justify-content:center; gap:6px;
  /* 手机端全宽 */
  width:100%;
  touch-action:manipulation;
  /* 触控安全高度 */
  min-height:48px;
}
.btn-copy:active { transform:scale(0.96); box-shadow:0 2px 8px rgba(245,158,11,0.3); }

/* ─── Toast ─── */
.toast {
  position:fixed; top:60px; left:50%; transform:translateX(-50%) translateY(-20px);
  background:var(--text-primary); color:#fff; padding:10px 20px;
  border-radius:var(--radius); font-size:13px; z-index:9999;
  opacity:0; pointer-events:none; transition:var(--transition); box-shadow:var(--shadow-lg);
  /* 手机端 Toast 宽度限制 */
  max-width:90vw; text-align:center;
}
.toast.show { opacity:1; transform:translateX(-50%) translateY(0); }
.toast--success { background:var(--success); }

/* ─── Footer ─── */
.site-footer {
  background:var(--text-primary); color:var(--text-muted);
  text-align:center; padding:16px; font-size:12px;
  padding-bottom: calc(16px + var(--safe-bottom));
}

/* ─── 动画 ─── */
@keyframes fadeInUp { from{opacity:0;transform:translateY(10px)} to{opacity:1;transform:translateY(0)} }

/* ─── iOS Safari 100vh 修正 ─── */
@supports(height:100dvh) {
  html { height:100dvh; }
  body { height:100dvh; }
}

/* ═══════════════════════════════════════
   PC 端适配（从移动端向上扩展）
   ═══════════════════════════════════════ */
@media(min-width:768px){
  .brand-header__inner{ padding:16px 24px; }
  .brand-header__logo{ font-size:22px; gap:12px; }
  .brand-header__logo-img{ width:46px; height:46px; }
  .brand-header__tagline{ font-size:13px; }

  .steps-bar{ padding:24px 16px 8px; }
  .step-item__num{ width:30px; height:30px; font-size:13px; }
  .step-item__label{ font-size:12px; }
  .step-divider{ width:28px; margin:0 6px; }

  .container{ padding:0 24px; }
  .section{ padding:20px 0; }
  .section__header{ margin-bottom:16px; }
  .section__title{ font-size:20px; }
  .section__title-num{ width:28px; height:28px; font-size:14px; }
  .section__lock-hint{ padding:32px 0; font-size:14px; }

  /* 产品卡片：PC端多列 */
  .product-grid{ grid-template-columns:repeat(auto-fill,minmax(240px,1fr)); gap:16px; }
  .product-card{
    padding:20px; border-radius:var(--radius-lg); min-height:100px;
    /* PC端启用hover效果 */
  }
  .product-card:hover { border-color:var(--primary); box-shadow:var(--shadow-lg); transform:translateY(-2px); }
  .product-card:active { transform:translateY(-2px); }
  .product-card__category{ font-size:12px; }
  .product-card__name{ font-size:16px; -webkit-line-clamp:unset; }
  .product-card__meta{ flex-direction:row; gap:12px; font-size:12px; }
  .product-card__price{ font-size:22px; }
  .product-card__price-unit{ font-size:13px; }

  /* 场景卡片：PC端更大 */
  .scene-grid{ grid-template-columns:repeat(auto-fill,minmax(170px,1fr)); gap:14px; }
  .scene-card{ padding:16px; border-radius:var(--radius); }
  .scene-card:hover{ border-color:var(--primary); box-shadow:var(--shadow); transform:translateY(-2px); }
  .scene-card__icon{ font-size:32px; }
  .scene-card__name{ font-size:14px; }

  /* 颜色选择器：PC端更宽松 */
  .color-picker{ grid-template-columns:repeat(auto-fill,60px); gap:12px; }
  .color-swatch{ width:60px; padding:6px 0; }
  .color-swatch__circle{ width:48px; height:48px; min-width:48px; min-height:48px; }
  .color-swatch:hover .color-swatch__circle{ border-color:var(--primary-hover); transform:scale(1.08); }
  .color-swatch:active .color-swatch__circle{ transform:scale(0.95); }
  .color-swatch__name{ font-size:11px; }

  /* 场景+颜色图预览：PC端限宽 */
  .scene-color-preview__img-wrap{ max-width:500px; }
  .scene-color-preview__label{ font-size:14px; }

  /* 面积输入 */
  .area-input-box{ padding:24px; border-radius:var(--radius-lg); }
  .area-input-box__label{ font-size:15px; }
  .area-input{ padding:14px 16px; }
  .area-input-wrapper{ max-width:400px; }
  .quick-btn{ padding:6px 14px; font-size:13px; }

  /* 结果区 */
  .result-section{ padding:24px 0 60px; }
  .result-empty{ padding:48px 24px; }
  .result-empty__icon{ font-size:48px; }
  .result-empty__text{ font-size:15px; }

  .result-card__header{ padding:20px 28px; }
  .result-card__title{ font-size:18px; }
  .result-card__badge{ font-size:12px; padding:4px 12px; }
  .result-card__body{ padding:28px; }

  .result-product-name{ font-size:22px; }
  .result-stats{ grid-template-columns:repeat(auto-fit,minmax(140px,1fr)); gap:16px; }
  .result-stat{ padding:16px; border-radius:var(--radius); }
  .result-stat__label{ font-size:12px; }
  .result-stat__value{ font-size:24px; }
  .result-stat__unit{ font-size:14px; }

  .calc-process{ padding:20px; margin-bottom:24px; border-radius:var(--radius); }
  .calc-process__title{ font-size:14px; }
  .calc-step{ font-size:13px; gap:10px; }
  .calc-step__num{ width:20px; height:20px; font-size:11px; }
  .calc-step__formula{ font-size:12px; padding:2px 6px; word-break:normal; }

  /* 结果底部：PC端横向排列 */
  .result-footer{
    padding:20px 28px; gap:16px;
    padding-bottom:20px;
  }
  .result-total__label{ font-size:14px; }
  .result-total__value{ font-size:32px; }
  .btn-copy{
    width:auto; padding:14px 40px; font-size:17px;
    min-height:52px;
  }
  .btn-copy:hover{ transform:translateY(-2px); box-shadow:0 6px 20px rgba(245,158,11,0.4); }
  .btn-copy:active{ transform:translateY(0); }

  .toast{ font-size:14px; padding:12px 24px; max-width:80vw; }
  .site-footer{ font-size:13px; padding:24px; padding-bottom:24px; }
}

@media(min-width:480px) and (max-width:767px){
  /* 平板/大手机：产品卡片可以更宽松 */
  .product-grid{ grid-template-columns:repeat(auto-fill,minmax(180px,1fr)); }
}
