/* 23 Mackay Drive · 修复清单
   视觉方向：验房工单／方格纸 —— 暖白纸、墨线、图章式编号、等宽数字。 */

:root {
  --paper: #f3ece0;
  --paper-card: #fffdf8;
  --paper-done: #f0eee6;
  --paper-void: #eae8e4;
  --ink: #1a1712;
  --ink-soft: #57503f;
  --ink-faint: #8b8271;
  --rule: #ded3bd;
  --rule-strong: #c3b69c;
  --red: #ad2417;
  --amber: #a76a05;
  --blue: #1e5b85;
  --green: #2f6b40;
  --gray: #6e6b64;
  --shadow: 2px 3px 0 rgba(26, 23, 18, 0.07);

  --font-display: "Songti SC", "Source Han Serif SC", "Noto Serif CJK SC", Georgia, "Times New Roman", serif;
  --font-body: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Menlo", "Consolas", monospace;

  --gutter: 16px;
  --tap: 44px;
  color-scheme: light;
}

* { box-sizing: border-box; }

/* 弹层用 display:flex，必须让 [hidden] 依然生效 */
[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  opacity: 0;
  overflow: hidden;
  clip-path: inset(50%);
}

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background-color: var(--paper);
  /* 方格纸底纹 */
  background-image:
    linear-gradient(rgba(140, 124, 94, 0.09) 1px, transparent 1px),
    linear-gradient(90deg, rgba(140, 124, 94, 0.09) 1px, transparent 1px);
  background-size: 22px 22px, 22px 22px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--blue); text-underline-offset: 3px; }

/* ---------- 报头 ---------- */

.masthead {
  position: sticky;
  top: 0;
  z-index: 30;
  background: linear-gradient(180deg, var(--paper) 88%, rgba(243, 236, 224, 0.92));
  border-bottom: 1px solid var(--rule-strong);
  padding-top: env(safe-area-inset-top);
  box-shadow: 0 1px 0 rgba(255, 253, 248, 0.9) inset;
}

.masthead__inner { padding: 12px var(--gutter) 0; max-width: 760px; margin: 0 auto; }

.masthead__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }

.masthead__eyebrow {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.masthead__title {
  margin: 2px 0 0;
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

.stamp-admin {
  flex: none;
  margin-top: 4px;
  padding: 3px 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--red);
  border: 1.5px solid currentColor;
  border-radius: 3px;
  transform: rotate(-3deg);
  opacity: 0.85;
}

/* 卷尺式进度 */
.gauge { margin-top: 12px; }

.gauge__track {
  position: relative;
  height: 10px;
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  background-image: repeating-linear-gradient(90deg, var(--rule) 0 1px, transparent 1px 10%);
  background-color: rgba(255, 253, 248, 0.6);
  overflow: hidden;
}

.gauge__fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: repeating-linear-gradient(-45deg, var(--green) 0 5px, #3a7d4c 5px 10px);
  transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

/* 进行中：接在已完成之后的一段浅色斜纹 */
.gauge__wip {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0;
  background: repeating-linear-gradient(-45deg,
    rgba(167, 106, 5, 0.55) 0 5px, rgba(167, 106, 5, 0.26) 5px 10px);
  transition: left 0.45s cubic-bezier(0.22, 1, 0.36, 1), width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.gauge__meta {
  margin: 5px 0 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

/* 标签页 */
.tabs { display: flex; gap: 20px; margin-top: 10px; }

.tab {
  position: relative;
  padding: 10px 0 12px;
  min-height: var(--tap);
  background: none;
  border: 0;
  font-size: 15px;
  color: var(--ink-faint);
  letter-spacing: 0.02em;
}

.tab.is-active { color: var(--ink); font-weight: 600; }

.tab.is-active::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 6px;
  height: 3px;
  background: var(--ink);
  border-radius: 2px;
}

/* ---------- 主体 ---------- */

main { max-width: 760px; margin: 0 auto; padding: 0 var(--gutter) 96px; }

.view { padding-top: 14px; }

/* 五个筛选，窄屏放不下就换行 */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }

.chip {
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.75);
  font-size: 14px;
  color: var(--ink-soft);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.chip.is-active { background: var(--ink); border-color: var(--ink); color: var(--paper-card); }

.notice {
  margin: 0 0 16px;
  padding: 12px 14px;
  font-size: 14px;
  color: var(--ink-soft);
  background: rgba(255, 253, 248, 0.85);
  border-left: 3px solid var(--rule-strong);
}

/* 区域分组 */
.group { margin-bottom: 26px; }

.group__head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}

.group__name {
  min-width: 0;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.group__rule { flex: 1; height: 1px; background: var(--rule-strong); }

.group__count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

/* ---------- 条目卡片 ---------- */

.list { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.card {
  position: relative;
  padding: 14px 14px 14px 16px;
  background: var(--paper-card);
  border: 1px solid var(--rule);
  border-left: 4px solid var(--accent, var(--rule-strong));
  border-radius: 3px;
  box-shadow: var(--shadow);
  animation: cardIn 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .card { animation: none; }
  .gauge__fill, .gauge__wip { transition: none; }
}

.card--defective { --accent: var(--red); }
.card--marginal { --accent: var(--amber); }
.card--custom { --accent: var(--blue); }

/* 进行中：不划线、不变淡，靠左侧施工斜纹条 + 图章一眼可辨 */
.card.is-wip {
  --accent: var(--amber);
  border-left-color: transparent;
  background-image: repeating-linear-gradient(-45deg,
    var(--amber) 0 4px, #d2921c 4px 8px);
  background-repeat: no-repeat;
  background-size: 4px 100%;
  background-position: left top;
}

.card.is-wip .badge { background: var(--amber); color: var(--paper-card); border-color: var(--amber); }

.stamp-wip, .stamp-void {
  flex: none;
  margin-left: auto;
  padding: 2px 7px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  color: var(--amber);
  border: 1.5px solid currentColor;
  border-radius: 3px;
  transform: rotate(-2deg);
  opacity: 0.9;
}

.stamp-void { color: var(--gray); }

/* 不修：整卡降饱和置灰，但不划线——划线是「已完成」的专属信号 */
.card.is-void {
  --accent: var(--gray);
  background: var(--paper-void);
  box-shadow: none;
}

.card.is-void .card__text,
.card.is-void .card__edit,
.card.is-void .card__label { color: var(--ink-faint); }
.card.is-void .rail img { opacity: 0.6; filter: grayscale(0.7); }
.card.is-void .badge { background: var(--gray); color: var(--paper-card); border-color: var(--gray); }

.card.is-done {
  --accent: var(--green);
  background: var(--paper-done);
  box-shadow: none;
}

.card.is-done .card__text,
.card.is-done .card__edit { text-decoration: line-through; text-decoration-thickness: 1px; color: var(--ink-faint); }
.card.is-done .card__label { color: var(--ink-faint); }
.card.is-done .rail img { opacity: 0.62; }

.card__head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }

.badge {
  flex: none;
  min-width: 40px;
  padding: 3px 7px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--accent);
  border: 1.5px solid currentColor;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.5);
}

.card.is-done .badge { background: var(--green); color: var(--paper-card); border-color: var(--green); }

.card__room {
  /* min-width:0 必须有，否则 nowrap 的英文房间名会把整页撑宽 */
  min-width: 0;
  font-size: 12px;
  color: var(--ink-faint);
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card__text { margin: 0; font-size: 16.5px; line-height: 1.5; letter-spacing: 0.01em; }

.card__source { margin: 7px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--ink-faint); }
.card__label { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-soft); }
.card__en { display: block; }

.card__note {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 8px 10px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-soft);
  background: rgba(243, 236, 224, 0.55);
  border: 1px dashed var(--rule-strong);
  border-radius: 3px;
  resize: vertical;
}

.card__note:focus { outline: 2px solid var(--blue); outline-offset: 1px; background: #fff; }

.note-ro {
  margin: 10px 0 0;
  padding: 8px 10px;
  font-size: 14px;
  color: var(--ink-soft);
  background: rgba(243, 236, 224, 0.55);
  border-left: 2px solid var(--rule-strong);
  white-space: pre-wrap;
}

.card__edit {
  width: 100%;
  padding: 8px 10px;
  font-size: 16.5px;
  line-height: 1.5;
  background: #fff;
  border: 1px solid var(--rule-strong);
  border-radius: 3px;
  resize: vertical;
}

/* 照片 */
.shots { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }

.shot__head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.shot__head::after { content: ""; flex: 1; height: 1px; background: var(--rule); }

.rail {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}

.rail::-webkit-scrollbar { height: 0; }

.thumb {
  position: relative;
  flex: none;
  scroll-snap-align: start;
  line-height: 0;
}

.thumb img {
  width: 92px;
  height: 92px;
  object-fit: cover;
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  background: var(--paper-done);
  cursor: zoom-in;
}

/* 图片取不到时不要露出浏览器的破图图标 */
.thumb.is-broken img { visibility: hidden; }

.thumb.is-broken::after {
  content: "图片暂不可用";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  line-height: 1.4;
  color: var(--ink-faint);
  border: 1px dashed var(--rule-strong);
  border-radius: 2px;
  background: var(--paper-done);
}

.thumb__del {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 24px;
  height: 24px;
  line-height: 1;
  border-radius: 50%;
  border: 1px solid var(--rule-strong);
  background: var(--paper-card);
  color: var(--red);
  font-size: 13px;
  box-shadow: var(--shadow);
}

.rail__add {
  flex: none;
  width: 92px;
  height: 92px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 1px dashed var(--rule-strong);
  border-radius: 2px;
  background: rgba(243, 236, 224, 0.5);
  color: var(--ink-soft);
  font-size: 12px;
}

.rail__add span:first-child { font-size: 19px; line-height: 1; }

/* 管理操作条 */
.ops {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--rule);
}

.op {
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--rule-strong);
  border-radius: 3px;
  background: var(--paper-card);
  font-size: 14px;
  color: var(--ink);
  transition: transform 0.1s;
}

.op:active { transform: translateY(1px); }
.op--del { margin-left: auto; color: var(--red); border-color: rgba(173, 36, 23, 0.4); }

/* 四段状态选择：当前态填色，点另一段即切换 */
.seg {
  display: flex;
  /* 不跟着宽屏一起拉长；窄屏放不下时「删除」自己换行 */
  flex: 0 1 360px;
  min-width: 0;
  border: 1px solid var(--rule-strong);
  border-radius: 3px;
  overflow: hidden;
}

.seg__btn {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  padding: 8px 4px;
  border: 0;
  border-left: 1px solid var(--rule);
  background: var(--paper-card);
  font-size: 14px;
  color: var(--ink-soft);
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.seg__btn:first-child { border-left: 0; }
.seg__btn:active { background: rgba(26, 23, 18, 0.06); }
.seg__btn[disabled] { opacity: 0.55; }

.seg__btn.is-on { background: var(--ink); border-left-color: var(--ink); color: var(--paper-card); font-weight: 600; }
.seg__btn.is-on[data-status="in_progress"] { background: var(--amber); border-left-color: var(--amber); }
.seg__btn.is-on[data-status="done"] { background: var(--green); border-left-color: var(--green); }
.seg__btn.is-on[data-status="wont_fix"] { background: var(--gray); border-left-color: var(--gray); }

.done-at {
  margin: 8px 0 0;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--green);
  letter-spacing: 0.04em;
}

/* ---------- 良好项 ---------- */

.good { display: flex; flex-direction: column; gap: 8px; }

.good__section {
  background: var(--paper-card);
  border: 1px solid var(--rule);
  border-radius: 3px;
  overflow: hidden;
}

.good__summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  min-height: var(--tap);
  cursor: pointer;
  list-style: none;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
}

.good__summary::-webkit-details-marker { display: none; }

.good__summary::after {
  content: "＋";
  margin-left: auto;
  font-family: var(--font-mono);
  font-weight: 400;
  color: var(--ink-faint);
}

.good__section[open] .good__summary::after { content: "－"; }

.good__n {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 400;
  color: var(--ink-faint);
}

.good__body { padding: 0 14px 8px; border-top: 1px dashed var(--rule); }

.good__row { padding: 10px 0; border-bottom: 1px dotted var(--rule); font-size: 14px; }
.good__row:last-child { border-bottom: 0; }
.good__row b { font-family: var(--font-mono); font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }
.good__row i { font-style: normal; color: var(--ink-faint); font-size: 12px; }
.good__row p { margin: 3px 0 0; color: var(--ink-soft); }

/* ---------- 页脚 / 悬浮按钮 ---------- */

.colophon {
  max-width: 760px;
  margin: 0 auto;
  padding: 22px var(--gutter) calc(28px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--rule-strong);
  text-align: center;
  font-size: 13px;
  color: var(--ink-faint);
}

.colophon p { margin: 0 0 4px; }
.colophon p:last-child { margin: 0; font-size: 15px; }
.colophon__sep { margin: 0 8px; color: var(--rule-strong); }

.fab {
  position: fixed;
  right: 18px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 25;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  font-size: 26px;
  line-height: 1;
  box-shadow: 3px 4px 0 rgba(26, 23, 18, 0.18);
}

.fab:active { transform: translateY(2px); box-shadow: 1px 2px 0 rgba(26, 23, 18, 0.18); }

/* ---------- 弹层 ---------- */

.sheet { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.sheet__scrim { position: absolute; inset: 0; background: rgba(26, 23, 18, 0.45); animation: fade 0.2s both; }

.sheet__panel {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 10px 18px calc(20px + env(safe-area-inset-bottom));
  background: var(--paper-card);
  border: 1px solid var(--rule-strong);
  border-radius: 12px 12px 0 0;
  animation: sheetIn 0.26s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheetIn { from { transform: translateY(18px); opacity: 0; } to { transform: none; opacity: 1; } }

.sheet__grip { width: 38px; height: 4px; margin: 2px auto 12px; border-radius: 2px; background: var(--rule-strong); }
.sheet__title { margin: 0; font-family: var(--font-display); font-size: 19px; }
.sheet__sub { margin: 4px 0 0; font-size: 13px; color: var(--ink-faint); }

.sheet__status {
  margin: 12px 0 0;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-soft);
}

.sheet__actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

.btn {
  min-height: var(--tap);
  padding: 10px 18px;
  border: 1px solid var(--rule-strong);
  border-radius: 3px;
  background: var(--paper-card);
  font-size: 15px;
}

.btn--primary { background: var(--ink); border-color: var(--ink); color: var(--paper-card); }
.btn[disabled] { opacity: 0.5; }

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 16px;
  padding: 26px 16px;
  text-align: center;
  border: 2px dashed var(--rule-strong);
  border-radius: 6px;
  background: rgba(243, 236, 224, 0.5);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.dropzone.is-over { border-color: var(--blue); background: rgba(30, 91, 133, 0.08); }
.dropzone__icon { font-size: 26px; line-height: 1; color: var(--ink-faint); }
.dropzone__main { font-size: 15px; }
.dropzone__hint { font-size: 12.5px; color: var(--ink-faint); }

kbd {
  padding: 1px 5px;
  font-family: var(--font-mono);
  font-size: 11px;
  border: 1px solid var(--rule-strong);
  border-bottom-width: 2px;
  border-radius: 3px;
  background: var(--paper-card);
}

.field { display: block; margin-top: 16px; }
.field__label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--ink-soft); }
.field__label em { font-style: normal; color: var(--red); font-size: 11px; }

.field textarea, .field select {
  width: 100%;
  padding: 10px 12px;
  font-size: 16px;
  background: #fff;
  border: 1px solid var(--rule-strong);
  border-radius: 3px;
  resize: vertical;
}

.field select { min-height: var(--tap); }

/* 大图 */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(18, 16, 12, 0.94);
  animation: fade 0.18s both;
  touch-action: none;
}

.lightbox img { max-width: 94vw; max-height: 82vh; object-fit: contain; }

.lightbox__close {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  right: 12px;
  width: var(--tap);
  height: var(--tap);
  border: 0;
  border-radius: 50%;
  background: rgba(255, 253, 248, 0.12);
  color: var(--paper-card);
  font-size: 18px;
}

.lightbox__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 66px;
  border: 0;
  background: rgba(255, 253, 248, 0.1);
  color: var(--paper-card);
  font-size: 30px;
  line-height: 1;
}

.lightbox__nav--prev { left: 6px; border-radius: 0 6px 6px 0; }
.lightbox__nav--next { right: 6px; border-radius: 6px 0 0 6px; }

.lightbox__meta {
  position: absolute;
  bottom: calc(18px + env(safe-area-inset-bottom));
  left: 0; right: 0;
  margin: 0;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 12px;
  color: rgba(255, 253, 248, 0.66);
}

/* toast / 状态 */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  z-index: 90;
  transform: translateX(-50%);
  max-width: 84vw;
  padding: 10px 16px;
  border-radius: 4px;
  background: rgba(26, 23, 18, 0.93);
  color: var(--paper);
  font-size: 14px;
  box-shadow: var(--shadow);
  animation: fade 0.16s both;
}

.toast--err { background: var(--red); }

.state {
  padding: 40px 10px;
  text-align: center;
  color: var(--ink-faint);
  font-size: 14px;
}

.state .btn { margin-top: 14px; }

.skeleton {
  height: 92px;
  margin-bottom: 12px;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: linear-gradient(90deg, rgba(255, 253, 248, 0.6), rgba(255, 253, 248, 0.95), rgba(255, 253, 248, 0.6));
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}

@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

@media (min-width: 620px) {
  .masthead__title { font-size: 32px; }
  .thumb img, .rail__add { width: 108px; height: 108px; }
}
