/* ===== tokens ===== */
:root {
  --bg:        #0f1115;
  --panel:     #161922;
  --panel-2:   #1c202b;
  --panel-3:   #232838;
  --line:      #2a3040;
  --line-soft: #212635;
  --text:      #e7eaf0;
  --muted:     #8992a4;
  --muted-2:   #646d80;
  --accent:    #e8834a;
  --accent-dim: rgba(232, 131, 74, .16);
  --danger:    #e0574a;
  --ok:        #43b581;

  /* 品质色的兜底值。必须放在 :root —— 若写在 .chip/.crop 等组件规则里，
     会与 .q-xxx 同特异性且后出现，导致品质色永远被兜底值覆盖 */
  --q:   150, 178, 198;
  --qbg: rgb(150, 178, 198);

  /* 铺在品质色实心底之上的深色文字 */
  --on-q:      #10131b;
  --on-q-dim:  rgba(16, 19, 27, .62);

  /* 品质色（RGB 三元组，便于叠加透明度） */
  --q-zhizhen: 121, 229, 255;
  --q-jinse:   245, 130, 50;
  --q-zise:    217, 144, 249;
  --q-lanse:   101, 199, 255;
  --q-lvse:    39, 215, 119;
  --q-huise:   150, 178, 198;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei",
               "PingFang SC", "Hiragino Sans GB", "Source Han Sans SC", sans-serif;
  font-size: 13.5px;
  -webkit-font-smoothing: antialiased;
}

body { display: flex; flex-direction: column; overflow: hidden; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2c3243; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #3a4258; }

/* ===== quality classes ===== */
/* 至臻 / 金色 是渐变底，其余为纯色底；--q 始终保留纯色，供描边与辉光使用 */
.q-zhizhen {
  --q: var(--q-zhizhen);
  --qbg: linear-gradient(115deg,
           rgb(121, 229, 255) 0%,
           rgb(238, 141, 250) 50%,
           rgb(121, 229, 255) 100%);
}
.q-jinse {
  --q: var(--q-jinse);
  --qbg: linear-gradient(115deg, rgb(245, 130, 50) 0%, rgb(255, 186, 49) 100%);
}
.q-zise  { --q: var(--q-zise);  --qbg: rgb(217, 144, 249); }
.q-lanse { --q: var(--q-lanse); --qbg: rgb(101, 199, 255); }
.q-lvse  { --q: var(--q-lvse);  --qbg: rgb(39, 215, 119);  }
.q-huise { --q: var(--q-huise); --qbg: rgb(150, 178, 198); }

/* ===== topbar ===== */
.topbar {
  flex: 0 0 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--panel);
}
.tabs { display: flex; gap: 4px; }
.tab {
  padding: 6px 18px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: .4px;
  transition: .15s;
}
.tab:hover { color: var(--text); background: var(--panel-2); }
.tab.is-on { color: #16110d; background: var(--accent); font-weight: 600; }

.save-flag {
  font-size: 12px;
  color: var(--ok);
  opacity: 0;
  transition: opacity .25s;
}
.save-flag.show { opacity: 1; }

/* 数据文件读取失败时的红色告警条 */
.err-bar {
  display: none;
  flex: 0 0 auto;
  padding: 10px 18px;
  font-size: 12.5px;
  line-height: 1.5;
  color: #ffd9d4;
  background: rgba(224, 87, 74, .16);
  border-bottom: 1px solid rgba(224, 87, 74, .45);
  word-break: break-all;
}
.err-bar.show { display: block; }
.err-bar b { color: #ffb3aa; }

/* ===== views ===== */
main { flex: 1 1 auto; min-height: 0; position: relative; }
.view { display: none; height: 100%; }
.view.is-on { display: flex; }

/* ===== 计算视图 ===== */
#view-calc { gap: 0; }

.col { min-height: 0; overflow: auto; }
.col-crops {
  flex: 0 0 236px;
  border-right: 1px solid var(--line-soft);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.col-work {
  flex: 1 1 auto;
  padding: 16px 20px 40px;
}
.col-result {
  flex: 0 0 292px;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line-soft);
  background: var(--panel);
  padding: 18px 18px 20px;
}

/* 校准区：钉在结果栏底部 */
.calib { margin-top: auto; padding-top: 20px; }
.calib-title {
  font-size: 11.5px;
  letter-spacing: 1px;
  color: var(--muted-2);
  margin-bottom: 8px;
}
.calib-row { display: flex; gap: 8px; align-items: stretch; }
.calib-row .input { flex: 1 1 auto; width: auto; min-width: 0; }
.calib-row .btn { flex: 0 0 auto; }
.calib-msg {
  margin-top: 8px;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--ok);
  min-height: 17px;
  word-break: break-all;
}
.calib-msg.err { color: var(--danger); }

.search {
  flex: 0 0 auto;
  margin: 12px 12px 8px;
  padding: 8px 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  outline: none;
  transition: .15s;
}
.search:focus { border-color: var(--accent); background: var(--panel-3); }
.search::placeholder { color: var(--muted-2); }

.crop-list { flex: 1 1 auto; overflow: auto; padding: 4px 10px 24px; }
.crop-list .qhead { margin: 14px 2px 8px; }
.crop-list .qhead:first-child { margin-top: 4px; }

/* 作物条目：整块实心品质底色 + 深色文字 */
.crop {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 11px;
  margin-bottom: 7px;
  border-radius: 8px;
  background: var(--qbg);
  color: var(--on-q);
  text-align: left;
  transition: filter .13s, box-shadow .13s, transform .13s;
}
.crop .nm { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crop .pr {
  flex: 0 1 auto;
  max-width: 116px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 600;
  color: var(--on-q-dim);
  font-variant-numeric: tabular-nums;
}
.crop:hover { filter: brightness(1.07); }
/* 未选中即为所给 RGB 原色；选中靠白色双环 + 右移来区分 */
.crop.is-on {
  filter: brightness(1.06);
  transform: translateX(3px);
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px #fff;
}

/* 品质分组标题：色块 + 品质名 + 数量 */
.qhead {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 2px 9px;
}
.qhead .sq {
  width: 12px; height: 12px;
  border-radius: 3px;
  background: var(--qbg);
  box-shadow: 0 0 9px rgba(var(--q), .55);
}
/* 品质名用渐变填充文字（background-clip:text） */
.qhead .qn {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 1px;
  background: var(--qbg);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.qhead .qc { font-size: 11px; color: var(--muted-2); }

/* work head */
.work-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line-soft);
}
.cur-crop {
  position: relative;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: .5px;
  padding-left: 13px;
  line-height: 1.2;
}
/* 左侧竖条用伪元素，才能吃到渐变色 */
.cur-crop::before {
  content: '';
  position: absolute;
  left: 0;
  top: 2px;
  bottom: 2px;
  width: 3px;
  border-radius: 3px;
  background: var(--qbg);
}
/* 渐变文字只作用在作物名上，避免影响到下面的品质小字 */
.cur-crop .cn {
  display: block;
  background: var(--qbg);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.cur-crop .ql {
  display: block;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 2px;
  color: var(--muted-2);
  margin-top: 3px;
}
.weight-field {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 12px;
}
.weight-field:focus-within { border-color: var(--accent); }
.weight-field input {
  width: 90px;
  border: none;
  background: none;
  outline: none;
  text-align: right;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.mini { font-size: 11.5px; color: var(--muted); }

/* mutation groups */
.mut-groups { display: flex; flex-direction: column; gap: 20px; }
.mgroup { display: block; }

.chips { display: flex; flex-wrap: wrap; gap: 9px; }

/* 词条筹码：整块实心品质底色 + 深色文字 */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 8px;
  border: none;
  background: var(--qbg);
  color: var(--on-q);
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
  user-select: none;
  transition: filter .13s, box-shadow .13s, transform .13s;
}
.chip .n { font-size: 13px; }
.chip .m { font-size: 10.5px; font-weight: 600; color: var(--on-q-dim); font-variant-numeric: tabular-nums; }
.chip .ty {
  font-size: 9px;
  font-weight: 700;
  line-height: 1.4;
  padding: 0 3px;
  border-radius: 3px;
  background: rgba(16, 19, 27, .2);
  color: rgba(16, 19, 27, .72);
}
.chip:hover { filter: brightness(1.07); }
/* 未选中即为所给 RGB 原色；选中靠白色双环 + 上浮 + 放大来区分 */
.chip.is-on {
  filter: brightness(1.06);
  transform: translateY(-2px) scale(1.04);
  z-index: 2;
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px #fff,
              0 6px 20px rgba(var(--q), .6);
}
.chip.pulse { animation: pulse .45s ease-out; }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px #fff, 0 0 24px 7px rgba(var(--q), .95); }
  100% { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px rgba(255, 255, 255, .92), 0 4px 16px rgba(var(--q), .5); }
}

.hint { color: var(--muted-2); font-size: 12px; padding: 6px 0; }

/* result */
.value-box {
  background: linear-gradient(160deg, var(--panel-3), var(--panel-2));
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 16px;
  margin-bottom: 16px;
}
.value-num {
  font-size: 29px;
  font-weight: 700;
  letter-spacing: .5px;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  word-break: break-all;
  line-height: 1.2;
}

.breakdown { display: flex; flex-direction: column; gap: 1px; }
.brow {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 7px 2px;
  font-size: 12.5px;
  border-bottom: 1px dashed var(--line-soft);
}
.brow .k { color: var(--muted); }
.brow .v { font-variant-numeric: tabular-nums; color: var(--text); }
.brow.total { border-bottom: none; padding-top: 11px; margin-top: 4px; border-top: 1px solid var(--line); }
.brow.total .k { color: var(--text); font-weight: 600; }
.brow.total .v { color: var(--accent); font-weight: 700; font-size: 14px; }

.synth-note { margin-top: 14px; display: flex; flex-direction: column; gap: 5px; }
.synth-note .sn {
  font-size: 11.5px;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  padding: 5px 9px;
}
.synth-note .sn b { color: var(--accent); font-weight: 600; }

/* ===== 数据视图 ===== */
#view-data { flex-direction: column; }
.data-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line-soft);
}
.subtabs { display: flex; gap: 4px; }
.subtab {
  padding: 6px 16px;
  border-radius: 8px;
  color: var(--muted);
  transition: .15s;
}
.subtab:hover { color: var(--text); background: var(--panel-2); }
.subtab.is-on { color: var(--text); background: var(--panel-3); font-weight: 600; }

.btn {
  padding: 7px 15px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  transition: .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--panel-3); border-color: #39415a; }
.btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: #16110d;
  font-weight: 600;
}
.btn.primary:hover { background: #f09157; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--panel-2); }
.btn.danger { color: var(--danger); border-color: rgba(224, 87, 74, .35); background: transparent; }
.btn.danger:hover { background: rgba(224, 87, 74, .12); }
.btn.sm { padding: 4px 11px; font-size: 12px; border-radius: 7px; }

.data-body { flex: 1 1 auto; min-height: 0; display: flex; }
.data-list-wrap { flex: 1 1 auto; min-width: 0; overflow: auto; padding: 14px 18px 40px; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: .5px;
  color: var(--muted);
  padding: 8px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  user-select: none;
}
.data-table th.sortable { cursor: pointer; }
.data-table th.sortable:hover { color: var(--text); }
.data-table th .ar { opacity: .45; font-size: 10px; margin-left: 3px; }
.data-table th.on .ar { opacity: 1; color: var(--accent); }

.data-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
  vertical-align: middle;
}
.data-table tbody tr:hover { background: var(--panel); }
.data-table td.num { font-variant-numeric: tabular-nums; color: var(--text); }
.data-table td.dim { color: var(--muted-2); }
.data-table td.act { text-align: right; white-space: nowrap; }
.data-table td.act .btn { margin-left: 6px; }

.qtag {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  background: var(--qbg);
  color: var(--on-q);
  border: none;
}

.ttag {
  font-size: 11.5px;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  padding: 1px 7px;
}
.ttag.innate { color: rgb(var(--q-zhizhen)); border-color: rgba(var(--q-zhizhen), .3); }
.ttag.weather { color: rgb(var(--q-lanse)); border-color: rgba(var(--q-lanse), .3); }
.ttag.special { color: rgb(var(--q-jinse)); border-color: rgba(var(--q-jinse), .3); }

/* form */
.data-form {
  flex: 0 0 380px;
  border-left: 1px solid var(--line-soft);
  background: var(--panel);
  overflow: auto;
  padding: 16px 18px 40px;
}
.data-form:empty { display: none; }
.form-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 16px;
  letter-spacing: .5px;
}
.field { margin-bottom: 13px; }
.field > label {
  display: block;
  font-size: 11.5px;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 5px;
}
.field .opt { color: var(--muted-2); font-size: 10.5px; letter-spacing: 0; }

.input, .select {
  width: 100%;
  padding: 7px 11px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  outline: none;
  transition: .15s;
}
.input:focus, .select:focus { border-color: var(--accent); background: var(--panel-3); }
.input::placeholder { color: var(--muted-2); }
.select { appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
}
.row2 { display: flex; gap: 10px; }
.row2 > * { flex: 1 1 0; min-width: 0; }

.sub-block {
  margin: 16px 0 14px;
  padding: 13px 13px 4px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--panel-2);
}
.sub-block .sb-title {
  font-size: 11.5px;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 11px;
}
.picker { max-height: 232px; overflow: auto; padding-right: 3px; }
.picker .mgroup { margin-bottom: 14px; }
.picker .mgroup:last-child { margin-bottom: 0; }
.picker .chip { padding: 4px 9px; }
.picker .chip .n { font-size: 12px; }
.picker .chip .m { font-size: 9.5px; }
.picker .qhead { margin-bottom: 7px; }
.picker .qhead .sq { width: 9px; height: 9px; }
.picker .qhead .qn { font-size: 11.5px; }
.picker .qhead .qc { font-size: 10.5px; }

.form-actions {
  display: flex;
  gap: 9px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
}
.form-actions .spacer { flex: 1 1 auto; }

.calc-out {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  border-radius: 8px;
  background: rgba(232, 131, 74, .1);
  border: 1px solid rgba(232, 131, 74, .3);
  font-size: 12px;
  color: var(--muted);
}
.calc-out b {
  color: var(--accent);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  margin-left: auto;
}

.empty-note { color: var(--muted-2); font-size: 12.5px; padding: 30px 0; text-align: center; }

/* ===== 方案记录 / 同种作物对比 ===== */
.plan-actions { display: flex; gap: 8px; margin-top: 12px; }
.plan-actions .btn { flex: 1 1 auto; padding: 7px 0; font-size: 12.5px; }
.plan-actions .btn[hidden] { display: none; }

.rec-body { flex: 1 1 auto; min-height: 0; display: flex; }
.rec-list-wrap { flex: 1 1 auto; min-width: 0; overflow: auto; padding: 14px 18px 40px; }
.rec-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.rec-title { font-size: 13px; font-weight: 600; color: var(--text); }
.rec-tools { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.rec-side {
  flex: 0 0 468px;
  border-left: 1px solid var(--line-soft);
  background: var(--panel);
  overflow: auto;
  padding: 14px 16px 30px;
}

/* 对比面板 */
.cmp-hint, .cmp-empty { color: var(--muted-2); font-size: 12.5px; line-height: 1.8; padding: 8px 2px; }
.cmp-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.cmp-title { font-size: 13px; font-weight: 600; }
.cmp-badge { font-size: 11px; padding: 2px 9px; border-radius: 999px; }
.cmp-badge.same { color: var(--ok); background: rgba(67, 181, 129, .14); }
.cmp-badge.diff { color: var(--danger); background: rgba(224, 87, 74, .14); }

.cmp-cols { display: flex; gap: 10px; align-items: flex-start; }
.cmp-col {
  flex: 1 1 0;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  padding: 10px 11px;
}
.cmp-col.win { border-color: rgba(232, 131, 74, .55); box-shadow: 0 0 0 1px rgba(232, 131, 74, .18); }
.cmp-name { font-size: 12.5px; font-weight: 600; margin-bottom: 2px; word-break: break-all; }
.cmp-sub { font-size: 11.5px; color: var(--muted); margin-bottom: 8px; }
.cmp-val { font-size: 17px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.cmp-val.small { font-size: 15px; }
.cmp-old { font-size: 11px; color: var(--muted-2); text-decoration: line-through; }
.cmp-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 9px; }
.mc {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-3);
  color: var(--text);
  white-space: nowrap;
}
.mc.both { color: var(--muted); }
.mc.onlya { color: #7cc4ff; border-color: rgba(124, 196, 255, .45); background: rgba(124, 196, 255, .12); }
.mc.onlyb { color: #ffb37c; border-color: rgba(255, 179, 124, .45); background: rgba(255, 179, 124, .12); }
.mc.added { color: var(--ok); border-color: rgba(67, 181, 129, .5); background: rgba(67, 181, 129, .14); }

.cmp-legend { display: flex; flex-wrap: wrap; gap: 10px; margin: 11px 0 2px; font-size: 11px; color: var(--muted); }
.cmp-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.lg-both { background: var(--panel-3); border: 1px solid var(--line); }
.lg-a { background: rgba(124, 196, 255, .65); }
.lg-b { background: rgba(255, 179, 124, .65); }
.lg-add { background: rgba(67, 181, 129, .75); }

.cmp-actions { margin-top: 12px; display: flex; gap: 8px; align-items: center; }
.cmp-actions .btn { padding: 7px 14px; font-size: 12.5px; }
.cmp-delta { margin-top: 11px; font-size: 12px; color: var(--muted); line-height: 1.7; }
.cmp-delta b { color: var(--text); }
.cmp-note { margin-top: 8px; font-size: 11.5px; color: var(--muted-2); line-height: 1.7; }
.rec-muts { color: var(--muted); font-size: 11.5px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-cb { width: 14px; height: 14px; accent-color: var(--accent); cursor: pointer; }

.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn:disabled:hover { background: var(--panel-2); border-color: var(--line); }
.ren-input { width: 100%; max-width: 190px; padding: 4px 8px; font-size: 12.5px; }

/* 对比组选择框 */
.cmp-pick {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--muted-2);
  cursor: pointer;
  user-select: none;
  margin: -2px 0 7px;
}
.cmp-pick input { accent-color: var(--accent); cursor: pointer; margin: 0; }
.cmp-col.win .cmp-pick { color: var(--accent); font-weight: 600; }

/* 对比框内可点击卸下的词条 */
.cmp-chips .chip[data-chip] { cursor: pointer; }
.cmp-chips .chip[data-chip]:hover { filter: brightness(1.3); }
.mc.off {
  opacity: .42;
  text-decoration: line-through;
  background: transparent;
  border-style: dashed;
}
.cmp-count { font-size: 11px; color: var(--muted); margin-top: 5px; }
.cmp-count .off-tag { color: var(--danger); }
.cmp-total { margin-left: auto; font-size: 11px; color: var(--muted-2); }

/* ===== 方案表 / 对比框：品质底色 + 分组框 ===== */

/* 品质底色的作物框（方案表作物列、对比框的「作物 · 重量」） */
.cropbox {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 7px;
  background: var(--qbg);
  color: var(--on-q);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

/* 方案表的词条列：改成可换行的品质筹码 */
.rec-muts {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  max-width: 320px;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}
.rec-muts .chip { font-size: 11px; padding: 2px 8px; border-radius: 6px; gap: 0; }

/* 对比框：四个分组框（共有 / 仅左 或 仅右 / 补上的） */
.cmp-chips { display: flex; flex-direction: column; gap: 7px; margin-top: 9px; }
.mcgroup {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 6px 7px 7px;
  background: rgba(255, 255, 255, .016);
}
.mcgroup .mcl {
  display: block;
  font-size: 10px;
  letter-spacing: .5px;
  color: var(--muted-2);
  margin-bottom: 5px;
}
.mcgroup .mcrow { display: flex; flex-wrap: wrap; gap: 4px; }
.mcgroup.g-both { border-color: rgba(150, 178, 198, .30); }
.mcgroup.g-a { border-color: rgba(124, 196, 255, .42); }
.mcgroup.g-b { border-color: rgba(255, 179, 124, .42); }
.mcgroup.g-add { border-color: rgba(67, 181, 129, .48); }
.mcgroup.g-add .mcl { color: var(--ok); }

/* 对比框里的筹码沿用计算页的品质底色；用描边区分归属 */
.cmp-chips .chip { font-size: 11.5px; padding: 3px 9px; border-radius: 7px; gap: 0; }
.cmp-chips .chip.off { opacity: .40; text-decoration: line-through; filter: grayscale(.55); }
.cmp-sub { margin-bottom: 8px; }

/* 左栏排序切换 */
.crop-sort {
  display: flex;
  gap: 6px;
  padding: 8px 10px 0;
}
.sbtn {
  flex: 1 1 auto;
  padding: 5px 0;
  font-size: 11.5px;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  transition: color .13s, background .13s, border-color .13s;
}
.sbtn:hover { color: var(--text); border-color: var(--line-soft); }
.sbtn.is-on {
  color: var(--on-q);
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}
/* 价值列：等宽数字 + 右侧对齐，方便纵向比较 */
.crop-list .crop .pr {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}

/* 右栏顶部：作物指标（价格系数 / 价值系数） */
.crop-metrics {
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.crop-metrics .brow { border-bottom: none; padding: 5px 2px; }
.crop-metrics .brow .k { color: var(--muted); }
.crop-metrics .brow .v { color: var(--text); font-weight: 600; }

/* 重量输入框的占位提示：字号小一点才能放进 90px 的框里（kg 单位本来就在框外） */
.weight-field input::placeholder {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted-2);
  letter-spacing: 0;
}

/* 被合成结果消耗掉的子词条：置灰、禁用（连子词条的子词条一起） */
.chips .chip.is-locked,
.chip.is-locked {
  opacity: .38;
  cursor: not-allowed;
  filter: grayscale(.6);
}
.chips .chip.is-locked .n,
.chip.is-locked .n {
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}
.chips .chip.is-locked:hover,
.chip.is-locked:hover {
  background: var(--panel-2);
  border-color: var(--line);
}

/* 互斥组标记（数据页词条表） */
.ttag.excl {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  cursor: help;
}

/* 数据表单里的可点选筹码（合成时吃掉 / 保留） */
.chip-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-height: 148px;
  overflow-y: auto;
  padding: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 9px;
}
.pchip {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 3.5px 8px;
  font-size: 12px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  transition: color .12s, background .12s, border-color .12s;
}
.pchip .m { font-size: 10px; opacity: .7; font-variant-numeric: tabular-nums; }
.pchip:hover { color: var(--text); border-color: var(--line-soft); }
.pchip.is-on {
  color: var(--on-q);
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 500;
}

/* 合成条件：原料 + 合成后是否还能再染 */
.syn-row {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}
.syn-row .field { margin: 0; }
/* 「额外吃掉」已选筹码：空的时候不占位，免得下面白留一条缝 */
.extra-picked { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 7px; }
.extra-picked:empty { display: none; }
.extra-picked .pchip .m { opacity: .5; font-size: 10px; }

/* ============================================================
   移动端适配（≤ 860px：手机 / 小平板）
   策略：放弃「固定视口 + 内部分栏滚动」，改成「整页竖排滚动」，
        三栏依次堆叠；表格横向滚动；触控目标加大。
   ============================================================ */
@media (max-width: 860px) {
  html, body { height: auto; }
  body {
    overflow: visible;
    font-size: 14px;
    -webkit-text-size-adjust: 100%;
  }

  /* 顶栏吸顶，滚动时切页始终可点 */
  .topbar {
    position: sticky;
    top: 0;
    z-index: 60;
    flex: 0 0 52px;
    padding: 0 10px;
    padding-top: env(safe-area-inset-top, 0);
  }
  .tab { padding: 8px 15px; font-size: 14px; }

  main { flex: none; min-height: 0; }
  .view { height: auto; }
  .view.is-on { display: flex; flex-direction: column; }
  .col { overflow: visible; }

  /* ---------- 计算页：作物条 → 工作区 → 结果 ---------- */
  .col-crops {
    flex: 0 0 auto;
    max-height: 40vh;
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
  }
  .crop-list { overflow: auto; padding: 2px 10px 12px; }
  .search { margin: 10px 10px 0; }
  .crop-sort { padding: 8px 10px 0; }

  .col-work { padding: 12px 13px 20px; }
  .work-head { flex-wrap: wrap; gap: 10px; }
  .weight-field { flex: 1 1 100%; }

  .col-result {
    flex: 0 0 auto;
    border-left: 0;
    border-top: 1px solid var(--line-soft);
    padding: 14px 13px calc(24px + env(safe-area-inset-bottom, 0));
  }
  .value-num { font-size: 34px; }

  /* ---------- 方案页：列表 → 对比面板 ---------- */
  .rec-body { flex-direction: column; }
  .rec-list-wrap {
    flex: none;
    overflow-x: auto;
    overflow-y: visible;
    padding: 12px 10px 18px;
  }
  .rec-head { flex-wrap: wrap; gap: 8px; }
  .rec-side {
    flex: none;
    border-left: 0;
    border-top: 1px solid var(--line-soft);
    overflow: visible;
    padding: 12px 10px calc(28px + env(safe-area-inset-bottom, 0));
  }
  .rec-body .data-table { min-width: 580px; }

  /* ---------- 数据页：列表 → 表单 ---------- */
  .data-head { padding: 10px 12px; gap: 8px; }
  .data-body { flex-direction: column; }
  .data-list-wrap {
    flex: none;
    overflow-x: auto;
    overflow-y: visible;
    padding: 12px 8px 16px;
  }
  .data-list-wrap .data-table { min-width: 640px; }
  .data-form {
    flex: none;
    border-left: 0;
    border-top: 1px solid var(--line-soft);
    overflow: visible;
    padding: 14px 12px calc(40px + env(safe-area-inset-bottom, 0));
  }

  /* ---------- 触控目标：都放大到约 36–40px ---------- */
  .chip { padding: 8px 12px; border-radius: 9px; }
  .chip .n { font-size: 13.5px; }
  .chip .m { font-size: 11px; }
  .pchip { padding: 8px 11px; font-size: 12.5px; }
  .btn { padding: 10px 15px; font-size: 14px; }
  .sbtn { padding: 7px 12px; }
  .crop { padding: 10px 10px; }
  input, select, textarea { font-size: 15px; }  /* ≥16px 可防 iOS 聚焦时自动放大，这里配合 meta 足够 */
  .input, .select, .search { padding: 10px 11px; }
  .weight-field input { width: 100%; }

  /* 高亮浮层别被挡住 */
  .toast, .save-flag { bottom: calc(18px + env(safe-area-inset-bottom, 0)); }
}

/* 超窄屏（iPhone SE 之类）再收紧一点 */
@media (max-width: 400px) {
  .col-work { padding: 10px 10px 16px; }
  .col-result { padding: 12px 10px 20px; }
  .value-num { font-size: 30px; }
  .tab { padding: 7px 11px; font-size: 13.5px; }
  .chip { padding: 7px 10px; }
  .chip .n { font-size: 13px; }
}

/* 移动端微调（放在后面，覆盖上面同特异性的规则） */
@media (max-width: 860px) {
  /* 「重量」「kg」别被挤成竖排 */
  .weight-field { flex-wrap: nowrap; }
  .weight-field .mini { flex: 0 0 auto; white-space: nowrap; }
  .weight-field input { min-width: 0; }

  /* 触控目标统一到 ≥34px（实测筹码原来 30px，点着偏小） */
  .chip { min-height: 34px; }
  .pchip { min-height: 34px; }
  .sbtn { min-height: 34px; }
}
