/* ===================== 主题变量 ===================== */
:root {
  --bg: #fff7ec;
  --bg2: #ffe9cf;
  --surface: #ffffff;
  --text: #3d2f1f;
  --text-soft: #9c8672;
  --border: #f0e2cf;
  --accent: #d99a4e;
  --accent-d: #c07f33;
  --accent-2: #e6a866;
  --accent-soft: #f7e8d3;
  --hero-1: #f3c78a;
  --hero-2: #d99a5f;
  --hero-3: #c07d4a;
  --weld: #c07f33;
  --weld-d: #a86b3c;
  --weld-soft: #f7e8d3;
  --yellow: #ffd400;
  --danger: #dc2626;
  --shadow-sm: 0 2px 8px rgba(160,110,60,.08);
  --shadow:    0 6px 20px rgba(160,110,60,.10), 0 12px 32px rgba(160,110,60,.06);
  --shadow-lg: 0 18px 40px rgba(160,110,60,.16);
  --radius: 22px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
html { background: var(--bg); }
body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
               -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: transparent;
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  display: flex; flex-direction: column;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
}
/* 顶部柔和光晕，避免之前"突兀渐变块"的问题 */
body::before {
  content: "";
  position: fixed; top: -8vh; left: 50%; transform: translateX(-50%);
  width: 140vw; height: 72vh;
  background: radial-gradient(ellipse at center, rgba(255,233,207,.95) 0%, rgba(255,247,236,.4) 45%, rgba(255,247,236,0) 72%);
  pointer-events: none; z-index: -1;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ===================== 顶部 Hero ===================== */
header.hero {
  position: relative;
  padding: 32px 20px 6px;
  text-align: center;
}
.hero-inner { position: relative; z-index: 1; display: inline-flex; flex-direction: column; align-items: center; }

header.hero h1 {
  font-size: clamp(36px, 5.5vw, 52px);
  font-weight: 800;
  letter-spacing: -.5px;
  background: linear-gradient(135deg, var(--weld-d) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 4px rgba(160,110,60,.08));
}

/* 漂浮的 Zzz，增加"瞌睡"氛围但保持克制 */
.hero .zzz {
  position: absolute;
  font-weight: 800;
  color: var(--accent);
  opacity: .20;
  pointer-events: none;
  animation: floatZ 2.8s ease-in-out infinite;
}
.hero .zzz.z1 { top: -10px; right: -26px; font-size: 18px; animation-delay: 0s; }
.hero .zzz.z2 { top: -22px; right: -44px; font-size: 13px; animation-delay: .75s; opacity: .13; }
.hero .zzz.z3 { top: 4px; right: -50px; font-size: 10px; animation-delay: 1.45s; opacity: .10; }
@keyframes floatZ {
  0%,100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-5px) scale(1.06); }
}


/* ===================== 容器 & 视图切换 ===================== */
.wrap { max-width: 880px; margin: 0 auto; padding: 0 20px; width: 100%; }
main  { flex: 1; padding-top: 16px; }
.view { display: none; animation: fadeUp .35s ease both; }
.view.active { display: block; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===================== 子页面通用 page-head ===================== */
.page-head { padding: 6px 0 18px; }
.page-head h2 { font-size: clamp(22px, 3vw, 28px); font-weight: 800; }
.page-head p  { color: var(--text-soft); font-size: 14px; margin-top: 6px; }
.weld-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}
.head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ===================== 通用搜索 + 分类 ===================== */
.controls { margin: 20px 0 24px; }
.search {
  width: 100%;
  padding: 13px 20px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 15px;
  color: var(--text);
  outline: none;
  box-shadow: var(--shadow-sm);
}
.search::placeholder { color: var(--text-soft); }
.search:focus { border-color: var(--accent-2); box-shadow: 0 0 0 4px rgba(217,154,78,.18); }
/* 去掉 search 类型输入框自带的清除按钮，避免破坏胶囊形状 */
.search[type="search"]::-webkit-search-decoration,
.search[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }


.empty { text-align: center; color: var(--text-soft); padding: 60px 20px; font-size: 15px; }


/* ===================== 机器选择栏 ===================== */
.machine-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 20px 0 0;
  flex-wrap: wrap;
}
.machine-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}
.machine-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  transition: transform .15s ease, box-shadow .2s ease, border-color .2s ease, background .2s ease, color .2s ease;
}
.machine-chip:hover { border-color: var(--accent-2); transform: translateY(-1px); }
.machine-chip.active {
  background: linear-gradient(135deg, var(--weld), var(--weld-d));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(192,127,51,.28);
}
.machine-name { white-space: nowrap; }
.machine-del {
  border: 0;
  background: transparent;
  color: inherit;
  opacity: .45;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.machine-del:hover { opacity: 1; background: rgba(0,0,0,.12); }
.machine-chip.active .machine-del:hover { background: rgba(255,255,255,.28); }
.machine-empty { color: var(--text-soft); font-size: 14px; }


/* ===================== 焊接参数 模块 ===================== */
.weld-list { display: flex; flex-direction: column; gap: 14px; padding-bottom: 24px; }
.card-wrap { position: relative; overflow: hidden; border-radius: var(--radius); }
.card-del {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 84px;
  z-index: 0;
  border: 0;
  background: linear-gradient(135deg, #e05252, var(--danger));
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.card-del:active { filter: brightness(.94); }
.card {
  position: relative;
  z-index: 1;
  touch-action: pan-y;            /* 横向手势留给滑动删除，纵向照常滚动 */
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .18s ease, box-shadow .25s ease;
  border: 1px solid var(--border);
}
.card.swiping { transition: none; }
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.card-title {
  font-size: 17px; font-weight: 700; color: var(--text);
}
.card-meta {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 8px;
}
.badge {
  font-size: 12px; font-weight: 600;
  color: #92400e;
  background: #fef3c7;
  padding: 4px 12px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge-muted { background: #f2ece3; color: #9c8672; }
.badge-def   { background: #f7e0cc; color: #a4551d; }

/* 卡片内的产品图片 */
.card-img {
  width: 100%;
  max-height: 280px;
  object-fit: contain;
  border-radius: 14px;
  margin-top: 14px;
  border: 1px solid var(--border);
  background: #fafbfc;
  display: block;
}
.param-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-top: 14px;
  font-size: 12px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--border);
}
.param-table th {
  background: var(--yellow);
  color: #1f2937;
  font-weight: 600;
  padding: 10px 4px;
}
.param-table td {
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 10px 4px;
  text-align: center;
  color: var(--text);
}
.param-table tr:nth-child(even) td { background: #fafbfc; }
.no-rows { font-size: 13px; color: var(--text-soft); margin: 12px 0 0; text-align: center; }

/* 焊接表单 */
.form-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.form-head span { font-weight: 600; font-size: 17px; }
.field-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.form label {
  display: block;
  font-size: 13px;
  color: var(--text-soft);
  margin: 14px 0 6px;
  font-weight: 500;
}
.field-group label:first-child { margin-top: 0; }
.form input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 15px;
  background: #fff;
  font-family: inherit;
  color: var(--text);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.form input:focus {
  border-color: var(--weld);
  box-shadow: 0 0 0 4px var(--weld-soft);
}
/* 表单内数字框（高压、偏转角度）隐藏上下调节箭头 */
.form input[type=number] {
  -moz-appearance: textfield;
  appearance: textfield;
}
.form input[type=number]::-webkit-outer-spin-button,
.form input[type=number]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* ---- 偏转：分段选择器 ---- */
.seg {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--accent-soft);
  border-radius: 999px;
}
.seg-btn {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text-soft);
  padding: 9px 8px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .18s ease, color .18s ease, box-shadow .18s ease;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active {
  background: #fff;
  color: var(--weld-d);
  box-shadow: 0 2px 8px rgba(160,110,60,.16);
}
.angle-wrap { animation: fadeUp .25s ease both; }
.unit-input { position: relative; }
.unit-input input { padding-right: 40px; }
.unit-input .unit {
  position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
  color: var(--text-soft); font-size: 15px; pointer-events: none;
}

/* ---- 产品图片 ---- */
.img-picker { margin-top: 2px; }
.img-preview {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fafbfc;
  display: block;
}
.img-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.img-hint { margin: 8px 0 0; font-size: 12px; color: var(--text-soft); }
.file-input { display: none; }

/* 拍照识别入口：虚线框强调「可选步骤」 */
button.ocr-btn {
  width: 100%;
  margin: 0 0 16px;
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-soft);
  background: #fafbfc;
  border: 1.5px dashed var(--border);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
button.ocr-btn:hover { background: var(--weld-soft); border-color: var(--text-soft); }
button.ocr-btn:disabled { opacity: .6; cursor: wait; }
button.ocr-btn .ocr-sub { font-size: 12px; font-weight: 400; color: var(--text-soft); }

.rows-section {
  margin-top: 16px;
  background: #fafbfc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.rows-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.rows-head span { font-size: 14px; font-weight: 600; color: var(--text); }
.rows-container { display: flex; flex-direction: column; gap: 10px; }
.row-input {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr 1fr 40px;
  gap: 6px;
  align-items: end;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
}
.fld { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fld > span { display: none; }   /* 桌面端隐藏标签，保持紧凑一行 */
.row-input input {
  width: 100%;
  padding: 9px 4px;
  font-size: 13px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f7f8fa;
  font-family: inherit;
  color: var(--text);
  outline: none;
  /* 隐藏数字输入框的上下调节小箭头 */
  -moz-appearance: textfield;
  appearance: textfield;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.row-input input::-webkit-outer-spin-button,
.row-input input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.row-input input:focus {
  background: #fff;
  border-color: var(--weld);
  box-shadow: 0 0 0 3px var(--weld-soft);
}
.row-del {
  width: 40px; height: 40px;
  padding: 0; border-radius: 10px;
  border: 1px solid var(--danger);
  background: #fff;
  color: var(--danger);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.row-del .del-txt { display: none; }

/* 按钮 */
button.primary {
  background: linear-gradient(135deg, var(--weld), var(--weld-d));
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(192,127,51,.28);
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}
button.primary:hover { box-shadow: 0 6px 18px rgba(192,127,51,.38); transform: translateY(-1px); }
button.ghost {
  background: #fff;
  color: var(--weld);
  border: 1px solid var(--weld);
  padding: 10px 19px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
button.ghost:hover { background: var(--weld-soft); }
button.small { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
button.danger {
  background: #fff;
  color: var(--danger);
  border: 1px solid var(--danger);
  width: 100%;
  margin-top: 14px;
  padding: 12px;
  border-radius: 12px;
  font-weight: 500;
  cursor: pointer;
}
button.danger:hover { background: #fef2f2; }
button.block { width: 100%; margin-top: 18px; padding: 14px; font-size: 15px; }
.hidden { display: none !important; }

/* ===================== 模态框 ===================== */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-mask { position: absolute; inset: 0; background: rgba(61,47,31,.38); backdrop-filter: blur(2px); }
.modal-card {
  position: relative;
  width: min(100%, 380px);
  background: var(--surface);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow-lg);
  animation: fadeUp .25s ease both;
}
.modal-card h3 { font-size: 18px; font-weight: 700; }
.modal-sub { color: var(--text-soft); font-size: 13px; margin-top: 6px; }
.modal-card input {
  width: 100%;
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.modal-card input:focus { border-color: var(--weld); box-shadow: 0 0 0 4px var(--weld-soft); }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; justify-content: flex-end; }
.modal-actions button { min-width: 92px; }
button.danger-solid {
  background: linear-gradient(135deg, #e05252, var(--danger));
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(220,38,38,.28);
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}
button.danger-solid:hover { box-shadow: 0 6px 18px rgba(220,38,38,.4); transform: translateY(-1px); }

/* ===================== 页脚 ===================== */
footer {
  padding: 32px 20px 44px;
  text-align: center;
  color: var(--text-soft);
  font-size: 13px;
}
footer .paw { font-size: 22px; margin-bottom: 8px; opacity: .8; }
footer a { color: var(--accent); }

/* ===================== 响应式 ===================== */
@media (max-width: 640px) {
  header.hero { padding: 24px 18px 6px; }
  header.hero h1 { letter-spacing: -.3px; }
  .hero .zzz.z1 { right: -22px; font-size: 16px; }
  .hero .zzz.z2 { right: -36px; font-size: 12px; }
  .hero .zzz.z3 { right: -40px; }
  .seg-btn { font-size: 13px; padding: 9px 4px; }
  .row-input {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px 8px;
    padding: 12px 10px;
    border-radius: 14px;
  }
  .fld > span { display: block; font-size: 11px; color: var(--text-soft); padding-left: 2px; }
  .fld:nth-child(5) { grid-column: span 2; }   /* 聚焦占两格，两行排满 */
  .fld input { text-align: left; padding: 10px 8px; font-size: 14px; border-radius: 10px; }
  .row-del {
    grid-column: 1 / -1;
    width: 100%;
    height: 36px;
    font-size: 13px;
    font-weight: 500;
    gap: 6px;
  }
  .row-del .del-ico { display: none; }
  .row-del .del-txt { display: inline; }
}
