html { touch-action: manipulation; }
/* ============================================================
 * 工艺助手 · 样式
 * 深色工业风：车间强光下低反光、高对比、大触控目标
 * ============================================================ */

:root {
  --bg: #0e1116;
  --bg2: #141920;
  --card: #1a2029;
  --card2: #212933;
  --line: #2b3441;
  --line2: #384453;
  --txt: #e9eef4;
  --dim: #93a1b0;
  --dim2: #6b7887;
  --acc: #ffb020;
  --acc-d: #d98f12;
  --cyan: #2dd4bf;
  --ok: #3ddc84;
  --warn: #ffa03a;
  --danger: #ff5c5c;
  --radius: 14px;
  --radius-s: 10px;
  --top-h: 52px;
  --tab-h: 60px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}

[data-theme="light"] {
  --bg: #f2f4f7;
  --bg2: #e8ecf1;
  --card: #ffffff;
  --card2: #f6f8fa;
  --line: #dbe1e8;
  --line2: #c6cfd9;
  --txt: #14181d;
  --dim: #5d6b7a;
  --dim2: #8a97a5;
  --acc: #b87400;
  --acc-d: #8f5a00;
  --cyan: #0f8f80;
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

/* ---------------- 顶栏 ---------------- */
#topbar {
  flex: 0 0 auto;
  height: calc(var(--top-h) + var(--safe-t));
  padding: var(--safe-t) 14px 0;
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(180deg, var(--bg2), var(--bg));
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 30;
}

.brand {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--txt);
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand::before {
  content: "";
  width: 4px;
  height: 16px;
  border-radius: 2px;
  background: var(--acc);
  display: block;
}

.brand-sub {
  font-size: 11px;
  color: var(--dim2);
  font-weight: 400;
  letter-spacing: 0.08em;
  margin-left: 2px;
}

.top-spacer { flex: 1; }

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--txt);
  font-size: 16px;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}
.icon-btn:active { background: var(--card2); }

/* ---------------- 内容区 ---------------- */
#view {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 14px 14px 24px;
  scrollbar-width: thin;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  margin: 2px 0 12px;
  letter-spacing: 0.02em;
}
.page-desc {
  font-size: 12.5px;
  color: var(--dim2);
  margin: -8px 0 14px;
  line-height: 1.6;
}

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}

.card-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: -2px 0 12px;
}
.card-t {
  font-size: 14.5px;
  font-weight: 650;
  display: flex;
  align-items: center;
  gap: 7px;
}
.card-t .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--acc); display: inline-block;
}
.card-note {
  font-size: 11.5px;
  color: var(--dim2);
}

/* ---------------- 表单 ---------------- */
.field { margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }

.field label {
  display: block;
  font-size: 12.5px;
  color: var(--dim);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}

.input, select.input {
  width: 100%;
  height: 46px;
  padding: 0 12px;
  border-radius: var(--radius-s);
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--txt);
  font-size: 16px;
  font-family: var(--mono);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}
select.input {
  font-family: inherit;
  background-image: linear-gradient(45deg, transparent 50%, var(--dim) 50%),
    linear-gradient(135deg, var(--dim) 50%, transparent 50%);
  background-position: calc(100% - 17px) 20px, calc(100% - 12px) 20px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
}
.input:focus {
  border-color: var(--acc);
  box-shadow: 0 0 0 3px rgba(255, 176, 32, 0.14);
}
.input::placeholder { color: var(--dim2); opacity: 0.7; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.unit-wrap { position: relative; }
.unit-wrap .unit {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: var(--dim2);
  pointer-events: none;
  font-family: var(--mono);
}
.unit-wrap .input { padding-right: 52px; }

/* ---------------- 分段控件 ---------------- */
.seg {
  display: flex;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 3px;
  gap: 3px;
  overflow-x: auto;
  scrollbar-width: none;
}
.seg::-webkit-scrollbar { display: none; }
.seg button {
  flex: 1 0 auto;
  min-width: 56px;
  height: 38px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--dim);
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  padding: 0 10px;
  white-space: nowrap;
}
.seg button.on {
  background: var(--acc);
  color: #1a1205;
  font-weight: 650;
}

/* ---------------- 结果 ---------------- */
.result {
  background: linear-gradient(160deg, var(--card2), var(--bg2));
  border: 1px solid var(--line2);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}
.result-main {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.result-num {
  font-family: var(--mono);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--acc);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.result-unit { font-size: 13px; color: var(--dim); }
.result-label { font-size: 11.5px; color: var(--dim2); letter-spacing: 0.06em; margin-bottom: 5px; text-transform: uppercase; }

.kv {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 13.5px;
}
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--dim); flex: 0 0 auto; }
.kv .v { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }

/* ---------------- 提示 ---------------- */
.hint {
  font-size: 12px;
  color: var(--dim2);
  line-height: 1.65;
  margin-top: 8px;
}
.hint code {
  font-family: var(--mono);
  background: var(--bg2);
  border: 1px solid var(--line);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11.5px;
}

.warnbox {
  border-left: 3px solid var(--warn);
  background: rgba(255, 160, 58, 0.08);
  padding: 10px 12px;
  border-radius: 0 8px 8px 0;
  font-size: 12.5px;
  color: #ffc98a;
  line-height: 1.6;
  margin-top: 10px;
}
.dangerbox {
  border-left: 3px solid var(--danger);
  background: rgba(255, 92, 92, 0.09);
  padding: 10px 12px;
  border-radius: 0 8px 8px 0;
  font-size: 12.5px;
  color: #ff9b9b;
  line-height: 1.6;
  margin-top: 10px;
}
.okbox {
  border-left: 3px solid var(--ok);
  background: rgba(61, 220, 132, 0.08);
  padding: 10px 12px;
  border-radius: 0 8px 8px 0;
  font-size: 12.5px;
  color: #8ee9b4;
  line-height: 1.6;
  margin-top: 10px;
}

/* ---------------- 按钮 ---------------- */
.btn {
  height: 46px;
  border-radius: var(--radius-s);
  border: 1px solid var(--line2);
  background: var(--card2);
  color: var(--txt);
  font-size: 14.5px;
  font-family: inherit;
  cursor: pointer;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn:active { transform: scale(0.985); }
.btn.primary {
  background: var(--acc);
  color: #1a1205;
  border-color: var(--acc);
  font-weight: 650;
}
.btn.ghost { background: transparent; }
.btn.danger { color: #ff9b9b; border-color: rgba(255, 92, 92, 0.4); background: rgba(255, 92, 92, 0.08); }
.btn.block { width: 100%; }
.btn.sm { height: 34px; font-size: 12.5px; padding: 0 12px; }
.btn:disabled { opacity: 0.45; }

.btn-row { display: flex; gap: 8px; margin-top: 12px; }
.btn-row .btn { flex: 1; }

/* ---------------- 底部导航 ---------------- */
#tabbar {
  flex: 0 0 auto;
  height: calc(var(--tab-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: flex;
  background: var(--bg2);
  border-top: 1px solid var(--line);
  position: relative;
  z-index: 40;
}
#tabbar button {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--dim2);
  font-size: 10.5px;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  padding: 0;
  position: relative;
  letter-spacing: 0.02em;
}
#tabbar button .ic {
  width: 22px;
  height: 22px;
  display: block;
  line-height: 0;
}
#tabbar button .ic svg { width: 22px; height: 22px; display: block; }
#tabbar button.on { color: var(--acc); }
#tabbar button.on::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 2px;
  background: var(--acc);
  border-radius: 0 0 2px 2px;
}
#tabbar button:active { background: rgba(255, 255, 255, 0.03); }

/* ---------------- 工具列表 ---------------- */
.tool-list { display: grid; grid-template-columns: 1fr; gap: 9px; }

/* ---------------- 常驻结果条 ---------------- */
.sticky-res {
  position: sticky;
  top: 0;
  z-index: 8;
  margin: -14px -14px 12px;
  padding: 9px 14px 10px;
  background: var(--bg);
  box-shadow: 0 -14px 0 var(--bg), 0 8px 14px -8px rgba(0, 0, 0, 0.55);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: baseline;
  gap: 9px;
  min-height: 0;
  overflow: hidden;
}
.sticky-res:empty { display: none; }
.sticky-res .sr-label {
  font-size: 11px;
  color: var(--dim2);
  letter-spacing: 0.04em;
  flex: 0 0 auto;
}
.sticky-res .sr-val {
  font-family: var(--mono);
  font-size: 25px;
  font-weight: 700;
  color: var(--acc);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.sticky-res .sr-unit { font-size: 12px; color: var(--dim); }
.sticky-res .sr-extra {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--dim);
  font-family: var(--mono);
  text-align: right;
  line-height: 1.35;
}

.tool-card {
  display: flex;
  align-items: center;
  gap: 11px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 13px;
}
.tool-card:active { background: var(--card2); }

.tool-ic {
  flex: 0 0 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255, 176, 32, 0.1);
  border: 1px solid rgba(255, 176, 32, 0.26);
  color: var(--acc);
  display: grid;
  place-items: center;
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1;
}
.tool-tx { min-width: 0; flex: 1; }
.tool-t { font-size: 14.5px; font-weight: 650; margin-bottom: 1px; letter-spacing: 0.01em; }
.tool-d { font-size: 11.5px; color: var(--dim2); line-height: 1.45; }
.tool-arrow { color: var(--dim2); font-size: 19px; flex: 0 0 auto; opacity: 0.6; }

/* ---------------- 弹层 ---------------- */
#mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s;
  z-index: 90;
  backdrop-filter: blur(2px);
}
#mask.on { opacity: 1; pointer-events: auto; }

#sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--card);
  border-radius: 18px 18px 0 0;
  border-top: 1px solid var(--line2);
  transform: translateY(102%);
  transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 95;
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--safe-b);
}
#sheet.on { transform: translateY(0); }
.sheet-grip {
  width: 36px; height: 4px; border-radius: 2px;
  background: var(--line2); margin: 8px auto 0;
}
.sheet-h {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px 6px;
  font-size: 15px; font-weight: 650;
}
.sheet-body { padding: 6px 16px 18px; overflow-y: auto; }

/* ---------------- Toast ---------------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tab-h) + var(--safe-b) + 18px);
  transform: translate(-50%, 12px);
  background: var(--acc);
  color: #1a1205;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 20px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s;
  z-index: 120;
  white-space: nowrap;
  max-width: 86vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- 表格 ---------------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th {
  text-align: left;
  color: var(--dim2);
  font-weight: 500;
  font-size: 11px;
  padding: 7px 6px;
  border-bottom: 1px solid var(--line2);
  white-space: nowrap;
  letter-spacing: 0.03em;
}
.tbl td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tbl tr:last-child td { border-bottom: 0; }
.tbl .hl td { color: var(--acc); }
.tbl-wrap { overflow-x: auto; margin: 0 -4px; }

/* ---------------- 标签 ---------------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  padding: 0 10px;
  border-radius: 13px;
  background: var(--bg2);
  border: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--dim);
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip.hot { border-color: var(--acc); color: var(--acc); }

/* ---------------- 符号板 ---------------- */
.symgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(66px, 1fr));
  gap: 7px;
}
.symbtn {
  height: 52px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--txt);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  cursor: pointer;
  padding: 0;
}
.symbtn .s { font-size: 20px; font-family: var(--mono); line-height: 1.1; }
.symbtn .n { font-size: 9px; color: var(--dim2); transform: scale(0.92); }
.symbtn:active { background: var(--acc); color: #1a1205; }
.symbtn:active .n { color: #1a1205; }

/* ---------------- 绘制示意 ---------------- */
.figd {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px;
  margin: 8px 0;
  display: flex;
  justify-content: center;
}
.figd svg { max-width: 100%; height: auto; display: block; }

/* ---------------- 其它 ---------------- */
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.muted { color: var(--dim2); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.small { font-size: 12px; }
.divider { height: 1px; background: var(--line); margin: 12px 0; }
.tap { cursor: pointer; }
.tap:active { opacity: 0.65; }

.empty {
  text-align: center;
  color: var(--dim2);
  padding: 40px 16px;
  font-size: 13px;
  line-height: 1.8;
}
.empty .big { font-size: 30px; display: block; margin-bottom: 10px; opacity: 0.4; }

.fade-in { animation: fade 0.22s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (min-width: 560px) {
  #view { padding: 18px max(18px, calc((100vw - 720px) / 2)); }
  #tabbar button .ic, #tabbar button .ic svg { width: 23px; height: 23px; }
  #tabbar button { font-size: 11px; }
}

/* ---------------- 多行文本 ---------------- */
textarea.input {
  height: auto;
  min-height: 72px;
  padding: 10px 12px;
  line-height: 1.55;
  font-family: inherit;
  font-size: 14.5px;
  resize: vertical;
  display: block;
}

/* ---------------- 折叠段 ---------------- */
.acc {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  margin-bottom: 9px;
  overflow: hidden;
}
.acc-h {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 13px;
  cursor: pointer;
  user-select: none;
}
.acc-h:active { background: var(--card2); }
.acc-n {
  flex: 0 0 26px;
  height: 26px;
  border-radius: 7px;
  background: rgba(255, 176, 32, 0.12);
  border: 1px solid rgba(255, 176, 32, 0.3);
  color: var(--acc);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--mono);
}
.acc-t { flex: 1; font-size: 14px; font-weight: 600; min-width: 0; }
.acc-chev {
  color: var(--dim2);
  font-size: 12px;
  transition: transform 0.2s;
  flex: 0 0 auto;
}
.acc.open .acc-chev { transform: rotate(90deg); }
.acc-b { display: none; padding: 0 13px 13px; }
.acc.open .acc-b { display: block; }
.acc.open .acc-h { border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.acc-badge {
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 9px;
  font-family: var(--mono);
  flex: 0 0 auto;
}
.acc-badge.risk { background: rgba(255, 92, 92, 0.16); color: var(--danger); }
.acc-badge.ok { background: rgba(61, 220, 132, 0.14); color: var(--ok); }

/* ---------------- 检查项 ---------------- */
.chk { padding: 11px 0; border-bottom: 1px dashed var(--line); }
.chk:last-child { border-bottom: 0; padding-bottom: 0; }
.chk-q { font-size: 13px; line-height: 1.55; margin-bottom: 8px; }
.chk-btns { display: flex; gap: 6px; }
.chk-btn {
  flex: 1;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--dim);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}
.chk-btn.on-pass { background: rgba(61, 220, 132, 0.14); border-color: var(--ok); color: var(--ok); font-weight: 600; }
.chk-btn.on-risk { background: rgba(255, 92, 92, 0.14); border-color: var(--danger); color: var(--danger); font-weight: 600; }
.chk-btn.on-na { background: rgba(139, 152, 166, 0.14); border-color: var(--dim); color: var(--dim); }
.chk-note { margin-top: 8px; display: none; }
.chk-note.show { display: block; }
.chk-why {
  font-size: 11px;
  color: var(--dim2);
  line-height: 1.55;
  margin-top: 6px;
  padding-left: 9px;
  border-left: 2px solid var(--line2);
}

/* ---------------- 步骤条 ---------------- */
.steps { display: flex; gap: 3px; margin-bottom: 12px; }
.steps .st {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
}
.steps .st.done { background: var(--acc); }

/* ---------------- 列表行 ---------------- */
.item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  margin-bottom: 8px;
}
.item-row:active { background: var(--card2); }
.item-main { flex: 1; min-width: 0; }
.item-t { font-size: 14px; font-weight: 600; }
.item-s { font-size: 11.5px; color: var(--dim2); margin-top: 2px; }
.item-r { font-size: 18px; color: var(--dim2); }

/* ---------------- 文件选择（拍照 / 相册） ----------------
 * 用真实 <input type=file> 铺满按钮区域：
 * 用户点的就是 input 本身，不依赖 input.click()，
 * 兼容 iOS Safari PWA 独立模式与各家内置浏览器。
 */
.file-btn { position: relative; display: block; }
.file-btn .btn { width: 100%; pointer-events: none; }
.file-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  font-size: 100px;
  -webkit-appearance: none;
  appearance: none;
}
.file-overlay:active + .btn,
.file-btn:active .btn { transform: scale(0.985); }

/* ============ 打印样式（工艺卡/工序卡） ============ */
@media print {
  #topbar, #tabbar, .btn-row, .icon-btn, #mask, #sheet, #toast,
  .sticky-res, [data-op] .icon-btn { display: none !important; }
  body, #view, html { background: #fff !important; color: #000 !important; }
  body { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .card { border: 1px solid #bbb !important; background: #fff !important;
          box-shadow: none !important; break-inside: avoid; page-break-inside: avoid; }
  .card-h, .card-t, .k, .v, .hint, .chip { color: #000 !important; }
  .chip { border: 1px solid #999 !important; background: #f5f5f5 !important; }
  .result-num, .mono { color: #000 !important; }
  #view { padding: 0 !important; }
  .fade-in { animation: none !important; }
}
/* 符号板：SVG 图形 */
.symbtn .s svg { width: 26px; height: 26px; display: block; margin: 0 auto; }
.symbtn.big .s svg { width: 30px; height: 30px; }
.symbtn.big { padding: 10px 4px; }