:root {
  --blue: #12294a;
  --blue-2: #2a4a7a;
  --bg: #f2f4f7;
  --card: #fff;
  --line: #dfe3e8;
  --text: #1a1a1a;
  --muted: #6b7280;
  --ok: #1f9d55;
  --ng: #c0392b;
  --warn: #d97706;
  --radius: 12px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
html { background: var(--blue); -webkit-text-size-adjust: 100%; }
body {
  font-family: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.55;
  padding-bottom: calc(100px + env(safe-area-inset-bottom, 0px));
  min-height: 100vh; min-height: 100dvh;
}
#app { max-width: 640px; margin: 0 auto; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center;
  background: var(--blue); color: #fff;
  padding: calc(10px + env(safe-area-inset-top, 0px)) max(8px, env(safe-area-inset-right, 0px)) 10px max(8px, env(safe-area-inset-left, 0px));
  isolation: isolate;
}
.topbar-title { min-width: 0; overflow-wrap: anywhere; flex: 1; text-align: center; font-weight: 600; font-size: 17px; }
.icon-btn {
  background: transparent; border: 0; color: #fff;
  font-size: 26px; width: 44px; height: 44px; line-height: 1;
  border-radius: 8px; flex-shrink: 0;
}
.icon-btn.ghost { opacity: 0; pointer-events: none; }
.icon-btn-text { font-size: 20px; }

.pad { padding: 14px; }
.brand-logo-wrap { text-align: center; padding: 6px 0 10px; }
.brand-logo { width: 160px; max-width: 60%; height: auto; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  margin: 10px 0;
}
.card-title { font-weight: 700; margin-bottom: 8px; }
.tappable { cursor: pointer; }
.tappable:active { background: #f0f4f9; }

.btn {
  display: inline-block; border: 1px solid var(--line);
  background: #fff; color: var(--text);
  border-radius: 10px; padding: 12px 16px; font-size: 16px;
  cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn.block { display: block; width: 100%; margin: 8px 0; }
.btn.primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn.small { padding: 7px 12px; font-size: 14px; }
.btn.warn { background: #fff7ed; border-color: #fdba74; color: var(--warn); }
.btn.danger { color: var(--ng); border-color: #f0c1bb; }
.btn.danger.ghost { background: #fff; }
.btn[disabled] { opacity: .35; pointer-events: none; }

.field { display: block; margin: 10px 0; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.inp {
  width: 100%; font-size: 16px; padding: 10px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
  font-family: inherit;
}
textarea.inp { resize: vertical; min-height: 64px; }
.inp.cap { font-size: 13px; padding: 6px 8px; margin-top: 4px; }

.progress { height: 8px; background: #e5e9ef; border-radius: 99px; overflow: hidden; margin: 8px 0 4px; }
.progress-bar { height: 100%; background: var(--blue-2); }
.progress.mini { height: 5px; margin: 6px 0 0; }

.catrow { padding: 10px 4px; border-bottom: 1px solid var(--line); }
.catrow:last-child { border-bottom: 0; }
.catrow-top { display: flex; align-items: center; gap: 8px; }
.catrow.untouched .row-main { color: var(--muted); }
.catrow.untouched .progress-bar { background: #cbd5e1; }
.catrow.done .progress-bar { background: var(--ok); }

.cathead { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 10px; }

.row {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 4px; border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; }
.row-main { flex: 1; }

.tag {
  display: inline-block; min-width: 30px; text-align: center;
  font-size: 12px; font-weight: 700; padding: 2px 6px; border-radius: 6px;
  background: #eef1f4; color: var(--muted);
}
.tag-OK { background: #e3f4ea; color: var(--ok); }
.tag-NG { background: #fbe6e3; color: var(--ng); }
.tag.mini { font-size: 11px; font-weight: 600; }

.catnav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 6px 0 12px; }

.item {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 12px; margin: 8px 0;
  border-left: 4px solid transparent;
}
/* 多人共驗：別人查過的項目 = 醒目琥珀色左邊條，避免重複查；自己查過 = 低調綠色 */
.item.by-other { border-left-color: var(--warn); background: #fffbf0; }
.item.by-me    { border-left-color: var(--ok); }
.item.by-anon  { border-left-color: #cbd5e1; }
.who-tag {
  display: inline-block; background: #fef3c7; color: #92400e;
  font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 5px; white-space: nowrap;
}
.who-tag.mine { background: #dcfce7; color: #166534; }
.catrow-by { margin-top: 4px; }
.cathead { flex-wrap: wrap; }
.item-name { font-size: 15px; margin-bottom: 8px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.item-quote { font-size: 12px; color: var(--muted); background: #f4f6f9; border-radius: 8px; padding: 6px 8px; margin: 6px 0; }
.item .photo-grid { margin: 8px 0 6px; }
.item-field { margin: 8px 0; }
.item-field-label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.photo-btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.photo-count { font-size: 13px; color: var(--muted); }

.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg-btn {
  flex: 1; padding: 10px 4px; font-size: 15px;
  border: 1px solid var(--line); background: #fff; border-radius: 9px; cursor: pointer;
}
.seg-btn.active { color: #fff; border-color: var(--blue); background: var(--blue); }
.seg-btn.active.a-OK { background: var(--ok); border-color: var(--ok); }
.seg-btn.active.a-NG { background: var(--ng); border-color: var(--ng); }
.seg-btn.active.a-NA { background: #6b7280; border-color: #6b7280; }

.chips, .chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.chip {
  padding: 6px 10px; font-size: 13px; border: 1px solid var(--line);
  background: #fff; border-radius: 99px; cursor: pointer;
}
.chip.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.chip.has-photo { border-color: var(--ok); color: var(--ok); }
.chip.has-photo.active { background: var(--ok); border-color: var(--ok); color: #fff; }
.chip.has-photo::before { content: "✓ "; }

.sev-head { font-weight: 700; margin: 16px 0 6px; color: var(--blue); }

.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 6px 0; }
.photo-cell { position: relative; }
.photo-cell img { width: 100%; aspect-ratio: 1/1; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.photo-del {
  position: absolute; top: 2px; right: 2px; width: 22px; height: 22px;
  border-radius: 99px; border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 15px; cursor: pointer;
}
.photo-tag {
  position: absolute; left: 2px; bottom: 2px; max-width: calc(100% - 8px);
  background: rgba(0,0,0,.55); color: #fff; font-size: 10px; padding: 2px 5px;
  border-radius: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hidden-file { display: none; }

#bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  max-width: 640px; margin: 0 auto;
}
#bottomnav a {
  flex: 1; text-align: center; padding: 12px 0; text-decoration: none;
  color: var(--muted); font-size: 14px;
}
#bottomnav a.active { color: var(--blue); font-weight: 700; }
.sync-badge { position: absolute; right: 8px; top: -11px; font-size: 10px; color: var(--warn); background: #fff7ed; border: 1px solid #fed7aa; border-radius: 99px; padding: 1px 7px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.sync-badge.ok { color: var(--ok); background: #e6f6ec; border-color: #bbe6ca; }
#bottomnav { position: fixed; z-index: 30; flex-wrap: wrap; padding-bottom: env(safe-area-inset-bottom, 0px); padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
#bottomnav a { min-height: 48px; }
#bottomnav .sync-badge { position: static; order: -1; flex: 0 0 100%; max-width: 100%; border-radius: 0; box-shadow: none; text-align: center; font: inherit; font-size: 12px; line-height: 24px; padding: 0 8px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-main { min-width: 0; overflow-wrap: anywhere; }
.card-title, .auth-status { overflow-wrap: anywhere; }
.catnav > * { min-width: 0; }
.catnav .btn { padding-left: 8px; padding-right: 8px; }
.inp.cap { font-size: 16px; }
.topbar::before { content: ''; position: absolute; background: var(--blue); left: 0; right: 0; top: calc(-1 * env(safe-area-inset-top, 0px)); height: env(safe-area-inset-top, 0px); pointer-events: none; }
.lightbox { padding-top: calc(16px + env(safe-area-inset-top, 0px)); padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
.ref-explorer-body { padding-bottom: env(safe-area-inset-bottom, 0px); }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } .btn:active { transform: none; } }

.toast {
  position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%) translateY(10px);
  background: #1a1a1a; color: #fff; padding: 10px 16px; border-radius: 99px;
  font-size: 14px; opacity: 0; transition: .25s; z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 拍照參考 ---------- */
.ref-seclist { margin-top: 6px; }
.ref-secrow { display: flex; align-items: center; gap: 12px; padding: 10px; }
.ref-secthumb {
  width: 64px; height: 64px; object-fit: cover; border-radius: 10px;
  border: 1px solid var(--line); flex-shrink: 0; background: #eef1f4;
}
.ref-secmeta { min-width: 0; }
.ref-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 8px; }
.ref-card { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.ref-thumb {
  width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block;
  background: #eef1f4; cursor: zoom-in;
}
.ref-cap { padding: 7px 8px; font-size: 12.5px; line-height: 1.4; }
.ref-loc {
  display: inline-block; background: var(--blue); color: #fff; font-size: 11px;
  padding: 1px 6px; border-radius: 5px; margin-right: 5px;
}
.ref-results { margin-top: 6px; }
.btn.small.ref-btn { background: #eef4ff; border-color: #bcd3f5; color: var(--blue); }

/* 檢查項目旁「參考」跳出的探索層 */
.ref-explorer {
  position: fixed; inset: 0; z-index: 210;
  background: var(--bg);
  display: flex; flex-direction: column;
}
.ref-explorer-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.ref-ex-hero {
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--card);
}
.ref-ex-hero img {
  width: 100%; max-height: 52vh; object-fit: contain;
  background: #000; display: block; cursor: zoom-in;
}
.ref-ex-cap { padding: 8px 10px; font-size: 13px; line-height: 1.5; }
.ref-ex-badge {
  display: inline-block; background: var(--ok); color: #fff; font-size: 11px;
  padding: 1px 7px; border-radius: 5px; margin-right: 6px;
}
.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,.9); z-index: 200;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 16px; gap: 12px;
}
.lightbox img { max-width: 100%; max-height: 82%; object-fit: contain; border-radius: 6px; }
.lightbox-cap { color: #fff; font-size: 14px; text-align: center; max-width: 90%; }
.ref-lightbox { z-index: 220; }

/* Installed iPhone web app: the system status area samples the page background. */
@media (display-mode: standalone) {
  body { background: var(--blue); }
  #app { background: var(--bg); min-height: calc(100vh - 100px - env(safe-area-inset-bottom, 0px)); min-height: calc(100dvh - 100px - env(safe-area-inset-bottom, 0px)); }
}
fieldset.item { min-inline-size:0; margin-inline:0; }
fieldset.item:disabled { opacity:.65; }
.team-device { padding:10px 0; border-bottom:1px solid #e5e7eb; overflow-wrap:anywhere; }
.team-device:last-child { border-bottom:0; }
.community-card,.community-unit { display:flex; width:100%; flex-direction:column; align-items:flex-start; gap:8px; text-align:left; font:inherit; color:var(--text); overflow-wrap:anywhere; }
.community-card { border-left:4px solid var(--blue-2); }
.community-card strong,.community-unit strong { font-size:20px; }
.community-tag { display:inline-block; font-size:13px; padding:3px 9px; border-radius:20px; background:#eaf0f8; color:var(--blue); }
.community-filters { display:grid; grid-template-columns:minmax(0,1fr) 120px; gap:8px; }
.community-return { display:block; padding:10px 16px; color:var(--blue); }
.community-view h2 { font-size:18px; }
.community-view details summary { cursor:pointer; padding:12px 0; }
.community-view textarea { resize:vertical; }
.community-panel { margin:12px 0; background:white; border:1px solid var(--line); border-radius:12px; padding:0 12px; }
.community-panel > summary { font-weight:600; color:var(--blue); }
.community-panel > form { border:0; padding:0; }

.live-checklist { overflow-anchor: none; }
.upload-photos-control { margin: 8px 0; }
.upload-photos-control [role="status"]:not(:empty) { margin-top: 4px; }
