:root {
  --paper: #f7f2e8;
  --card: #fffdf9;
  --ink: #24211d;
  --ink-2: #575046;
  --ink-3: #6e6559;
  --line: #e4dac9;
  --line-soft: #efe7d8;
  --red: #af3a2b;
  --red-bg: #fbeeeb;
  --orange: #b96b30;
  --orange-bg: #fbf0e4;
  --yellow: #8a6b21;
  --yellow-bg: #f8f2df;
  --green: #4c7451;
  --seal: #a8332a;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

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

html, body { margin: 0; padding: 0; }

body {
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.6 "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  padding-bottom: calc(76px + var(--safe-b));
  overflow-x: hidden;
}

/* 顶栏 */
.m-top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  background: rgba(247, 242, 232, .96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
.m-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.m-shield { width: 30px; height: 30px; color: var(--seal); flex: none; }
.m-brand h1 { margin: 0; font-size: 19px; letter-spacing: .12em; font-family: "Songti SC", "SimSun", serif; }
.m-brand p { margin: 0; font-size: 11px; color: var(--ink-3); }
.m-badge {
  flex: none;
  font-size: 11px;
  color: var(--ink-2);
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 4px 9px;
  white-space: nowrap;
}

/* 主体 */
.m-main {
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 14px 8px;
  display: grid;
  gap: 12px;
}

.m-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}

.m-selects { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 10px; }
.m-field { display: grid; gap: 4px; min-width: 0; }
.m-field span { font-size: 11px; color: var(--ink-3); }
.m-field select {
  width: 100%;
  min-width: 0;
  height: 42px;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: #fffefb;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 10px;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #8b8175 50%), linear-gradient(135deg, #8b8175 50%, transparent 50%);
  background-position: calc(100% - 16px) 18px, calc(100% - 11px) 18px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

#mEditor {
  display: block;
  width: 100%;
  min-height: 168px;
  max-height: 46vh;
  resize: vertical;
  font: inherit;
  font-size: 15px;
  line-height: 1.8;
  color: var(--ink);
  background: #fffefb;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}
#mEditor:focus { outline: 2px solid rgba(168, 51, 42, .35); outline-offset: 1px; }
#mEditor::placeholder { color: #b5aa99; }

.m-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--ink-3);
}
.m-meta-btns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.m-btn {
  font: inherit;
  font-size: 14px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-2);
  cursor: pointer;
}
.m-btn.small { min-height: 34px; font-size: 12.5px; padding: 0 10px; }
.m-btn.ghost { background: #fffefb; }
.m-btn.primary { background: var(--seal); border-color: var(--seal); color: #fff8ef; font-weight: 600; }
.m-btn:active { transform: translateY(1px); }
.m-btn:disabled { opacity: .5; }

/* 分数 */
.m-score {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}
.m-score-num { display: flex; align-items: baseline; gap: 2px; flex: none; }
.m-score-num span { font-size: 40px; font-weight: 700; line-height: 1; letter-spacing: -.02em; }
.m-score-num small { font-size: 12px; color: var(--ink-3); }
.m-score-info { min-width: 0; }
.m-grade { font-size: 17px; font-weight: 700; letter-spacing: .02em; }
.m-grade.green { color: var(--green); }
.m-grade.amber { color: var(--yellow); }
.m-grade.orange { color: var(--orange); }
.m-grade.red { color: var(--red); }
.m-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.m-pill { font-size: 11.5px; padding: 2px 8px; border-radius: 999px; }
.m-pill.red { color: var(--red); background: var(--red-bg); }
.m-pill.orange { color: var(--orange); background: var(--orange-bg); }
.m-pill.yellow { color: var(--yellow); background: var(--yellow-bg); }
.m-pill.green { color: var(--green); background: #eef3ec; }

/* 标签页 */
.m-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  background: #efe7d8;
  border-radius: 12px;
  padding: 4px;
  position: sticky;
  top: calc(52px + var(--safe-t));
  z-index: 8;
}
.m-tab {
  min-height: 40px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  font: inherit;
  font-size: 13.5px;
  color: var(--ink-2);
  cursor: pointer;
}
.m-tab span { font-size: 11px; opacity: .7; margin-left: 2px; }
.m-tab.active { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, .06); }

.m-panes { min-height: 120px; }
.m-pane { display: none; }
.m-pane.active { display: grid; gap: 10px; }

/* 问题卡片 */
.m-finding {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--ink-3);
  border-radius: 12px;
  padding: 12px;
}
.m-finding[data-sev="red"] { border-left-color: var(--red); }
.m-finding[data-sev="orange"] { border-left-color: var(--orange); }
.m-finding[data-sev="yellow"] { border-left-color: var(--yellow); }
.m-finding.hit { box-shadow: 0 0 0 2px #d9c6a4; }

.m-f-head { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.m-sev { font-size: 11px; color: #fff; padding: 1px 7px; border-radius: 4px; font-weight: 600; }
.m-sev.red { background: var(--red); }
.m-sev.orange { background: var(--orange); }
.m-sev.yellow { background: var(--yellow); }
.m-f-title { font-size: 14.5px; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.m-f-id { margin-left: auto; font-size: 10.5px; color: var(--ink-3); font-family: ui-monospace, monospace; }

.m-quote {
  margin: 8px 0 6px;
  font-size: 14px;
  background: linear-gradient(transparent 60%, #f6e6b8 60%);
  display: inline-block;
  padding: 0 2px;
}
.m-f-detail { margin: 0; }
.m-f-detail summary {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--seal);
  cursor: pointer;
  list-style: none;
  padding: 4px 0;
}
.m-f-detail summary::-webkit-details-marker { display: none; }
.m-f-detail summary::before { content: "▸ "; }
.m-f-detail[open] summary::before { content: "▾ "; }
.m-f-detail dt { font-size: 11.5px; color: var(--ink-3); margin-top: 8px; }
.m-f-detail dd { margin: 2px 0 0; font-size: 13px; color: var(--ink-2); line-height: 1.65; }
.m-f-actions { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.m-fix { font-size: 12px; color: var(--green); background: #eef3ec; border-radius: 6px; padding: 3px 8px; }

/* 核验 */
.m-evidence { display: grid; gap: 8px; }
.m-ev {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}
.m-ev-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.m-ev-head strong { font-size: 14px; }
.m-ev-head span { font-size: 11.5px; color: var(--ink-3); }
.m-ev p { margin: 6px 0 0; font-size: 13px; color: var(--ink-2); line-height: 1.65; }
.m-need { display: inline-block; margin-top: 8px; font-size: 11.5px; padding: 2px 8px; border-radius: 999px; background: #f8f2df; color: var(--yellow); }
.m-need.must { background: var(--red-bg); color: var(--red); }

/* 命中视图 */
.m-marked {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  font-size: 15px;
  line-height: 2;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.m-marked mark { background: transparent; padding: 1px 3px; border-radius: 4px; cursor: pointer; }
.m-marked mark.red { background: #f6d3cb; box-shadow: inset 0 -2px 0 var(--red); }
.m-marked mark.orange { background: #f8e2ca; box-shadow: inset 0 -2px 0 var(--orange); }
.m-marked mark.yellow { background: #f5ebc4; box-shadow: inset 0 -2px 0 var(--yellow); }

/* 依据 */
.m-basis { display: grid; gap: 8px; }
.m-basis-item { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.m-basis-item strong { font-size: 13.5px; }
.m-basis-item ul { margin: 6px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--ink-2); display: grid; gap: 4px; }

.m-empty {
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 28px 16px;
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
}

/* 底部操作栏 */
.m-actions {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 10px;
  padding: 10px 14px calc(10px + var(--safe-b));
  background: rgba(255, 253, 249, .97);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(6px);
  max-width: 560px;
  margin: 0 auto;
}

/* 底部弹层 */
.m-sheet { position: fixed; inset: 0; z-index: 40; }
.m-sheet[hidden] { display: none; }
.m-sheet-mask { position: absolute; inset: 0; background: rgba(36, 33, 29, .42); }
.m-sheet-body {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--card);
  border-radius: 16px 16px 0 0;
  border-top: 1px solid var(--line);
  padding: 12px 14px calc(12px + var(--safe-b));
  max-height: 78vh;
  display: flex;
  flex-direction: column;
  animation: sheet-up .2s ease;
}
@keyframes sheet-up { from { transform: translateY(12px); opacity: .6; } to { transform: none; opacity: 1; } }
.m-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--line-soft); }
.m-sheet-list { overflow-y: auto; -webkit-overflow-scrolling: touch; padding-top: 8px; display: grid; gap: 6px; }
.m-sheet-list button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-height: 52px;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: #fffefb;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
}
.m-sheet-list button span { font-size: 11.5px; color: var(--ink-3); }

/* 提示 */
.m-toast {
  position: fixed;
  left: 50%;
  bottom: calc(88px + var(--safe-b));
  transform: translateX(-50%);
  background: rgba(36, 33, 29, .94);
  color: #fbf6ea;
  font-size: 13px;
  padding: 9px 14px;
  border-radius: 10px;
  z-index: 50;
  max-width: calc(100% - 32px);
}
.m-toast[hidden] { display: none; }

/* 稍大屏：两列分数/操作保持单列，仅放宽内边距 */
@media (min-width: 560px) {
  .m-main { padding: 16px 18px 8px; }
  .m-actions { padding-left: 18px; padding-right: 18px; }
}
