:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #1b1c20;
  --muted: #6b6d76;
  --line: #dfe1e6;
  --accent: #1c3f99;
  --accent-ink: #ffffff;
  --a: #1f8a3b;
  --b: #c27c00;
  --c: #c0262d;
  --radius: 12px;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

header.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: var(--accent);
  color: var(--accent-ink);
}
header.top h1 { flex: 1; margin: 0; font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
header.top a, header.top button { color: inherit; background: none; border: 0; font: inherit; text-decoration: none; padding: 6px 8px; }

main { max-width: 980px; margin: 0 auto; padding: 16px 16px 80px; }

.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.card h2 { margin: 0 0 10px; font-size: 18px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.muted { color: var(--muted); font-size: 15px; }
.grow { flex: 1; min-width: 0; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list a, .list .item { display: flex; gap: 12px; align-items: center; padding: 12px 4px; color: inherit; text-decoration: none; }
.list .title { font-weight: 600; }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.danger { color: var(--c); }
button.small { min-height: 36px; padding: 0 12px; font-size: 15px; }

input, select, textarea {
  width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink); font: inherit;
}
textarea { min-height: 80px; resize: vertical; }
label { display: block; margin-bottom: 12px; font-size: 15px; color: var(--muted); }
label > input, label > select, label > textarea { margin-top: 4px; color: var(--ink); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 600px) { .grid2 { grid-template-columns: 1fr; } }

.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 34px; border-radius: 8px; font-weight: 700; color: #fff; background: #b7b9c0; }
.badge.A { background: var(--a); }
.badge.B { background: var(--b); }
.badge.C { background: var(--c); }

.rating { display: flex; gap: 8px; }
.rating button { flex: 1; min-height: 54px; }
.rating button.on.A { background: var(--a); color: #fff; border-color: var(--a); }
.rating button.on.B { background: var(--b); color: #fff; border-color: var(--b); }
.rating button.on.C { background: var(--c); color: #fff; border-color: var(--c); }

.check { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.check:first-child { border-top: 0; }
.check .label { flex: 1; }
.tri { display: flex; gap: 6px; }
.tri button { min-width: 64px; min-height: 40px; padding: 0 10px; font-size: 15px; }
.tri button.on.ok { background: var(--a); color: #fff; border-color: var(--a); }
.tri button.on.defect { background: var(--c); color: #fff; border-color: var(--c); }
.tri button.on.na { background: #8a8c94; color: #fff; border-color: #8a8c94; }

.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin-top: 8px; }
.photos figure { position: relative; margin: 0; aspect-ratio: 4/3; border-radius: 8px; overflow: hidden; background: #ddd; }
.photos img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photos .x { position: absolute; top: 4px; right: 4px; min-height: 30px; width: 30px; padding: 0; border-radius: 15px; background: rgba(0,0,0,.6); color: #fff; border: 0; }

.defect { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-top: 10px; }
.hint { background: #fff7e6; border: 1px solid #f1d9a6; border-radius: 10px; padding: 10px 12px; font-size: 15px; margin-bottom: 10px; }

dialog { border: 0; border-radius: 16px; padding: 0; width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 40px); }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog form { padding: 18px; }
dialog h2 { margin: 0 0 14px; }
dialog .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }

.stamp-preview { max-height: 120px; max-width: 100%; display: block; margin: 6px 0; }
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 20px); transform: translateX(-50%); background: #222; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 50; }
.hidden { display: none !important; }
