/* 현장 점검 기록 — 흰 점검 시트, 흑연 회색, 신호등 3색, 직각과 도장 모서리 표식, 촘촘한 장부 밀도.
   설계: 항목 줄은 "도장이 찍히는 점검 카드", 사진 묶음은 "오른쪽에 쌓인 사진 더미"를 항목으로 끌어다 놓는 대조대.
   잠금 계약: 글자 크기 5종 이하(12·14·16·24·40), 모서리 반경 2종 이하(0·2px), 간격 6단계 이하(4·8·12·16·24·32), 강조색 3종(초록·황·적). */
:root {
  --ink: #14181d; --muted: #566069; --line: #c5cbd1; --paper: #ffffff; --bg: #eceeed; --wash: #f5f6f6;
  --ok: #17703f; --warn: #946200; --bad: #b0281c;
  --font: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: light; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font); font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.top, main, .foot { max-width: 1180px; margin: 0 auto; padding-left: 16px; padding-right: 16px; }
.top { padding-top: 16px; padding-bottom: 4px; }
h1 { margin: 0; font-size: 16px; font-weight: 800; letter-spacing: 0.02em; }
h1 small { font-size: 12px; font-weight: 600; color: var(--muted); margin-left: 8px; }
h2 { margin: 0; font-size: 24px; line-height: 1.25; letter-spacing: -0.02em; }
h3 { margin: 0 0 4px; font-size: 16px; }
h4 { margin: 0; font-size: 16px; }
.hint { margin: 4px 0 12px; color: var(--muted); font-size: 12px; }
main { padding-bottom: 32px; }

/* 점검 시트: 도장 모서리 표식 */
.sheet { position: relative; background: linear-gradient(rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0.78)), var(--paper) url("assets/illustrations/paper-tile.webp") 0 0 / 240px 240px; border: 1px solid var(--line); border-radius: 0; padding: 16px; margin: 16px 0; }
.sheet::before, .sheet::after { content: ""; position: absolute; width: 12px; height: 12px; border: 2px solid var(--ink); pointer-events: none; }
.sheet::before { top: -2px; left: -2px; border-right: 0; border-bottom: 0; }
.sheet::after { bottom: -2px; right: -2px; border-left: 0; border-top: 0; }

.field { display: block; margin: 12px 0 4px; font-size: 12px; font-weight: 700; color: var(--muted); }
.field-inline { font-size: 12px; font-weight: 700; color: var(--muted); }
textarea, input[type="text"], select { width: 100%; font: inherit; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 2px; padding: 8px 12px; }
select { width: auto; max-width: 100%; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 12px 0; }
button { font: inherit; font-weight: 700; border-radius: 2px; border: 1px solid var(--ink); padding: 8px 16px; cursor: pointer; min-height: 40px; transition: transform 0.12s var(--ease), background 0.12s; }
button:active:not(:disabled) { transform: translateY(1px); }
button.primary { background: var(--ink); color: #fff; }
button.primary:hover { background: #2b333b; }
button.secondary { background: var(--paper); color: var(--ink); }
button.secondary:hover:not(:disabled) { background: var(--wash); }
button.plain { background: transparent; color: var(--ink); border-color: var(--line); }
button.danger { color: var(--bad); border-color: var(--bad); }
button.danger-solid { background: var(--bad); color: #fff; border-color: var(--bad); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
.check { display: inline-flex; gap: 8px; align-items: center; font-size: 14px; }

/* ── 시작 화면 ── */
.start { display: grid; gap: 32px; margin-top: 24px; }
.kicker { margin: 0 0 8px; font-size: 12px; font-weight: 800; letter-spacing: 0.14em; color: var(--muted); }
.start h2 { font-size: 40px; line-height: 1.15; letter-spacing: -0.03em; margin-bottom: 16px; text-wrap: balance; }
.steps { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 8px; }
.steps li { display: flex; gap: 12px; align-items: center; font-size: 16px; }
.steps b { flex: none; width: 24px; height: 24px; display: grid; place-items: center; border: 2px solid var(--ink); font-size: 12px; }
.preview { position: relative; align-self: start; background: var(--paper); border: 1px solid var(--line); padding: 16px; transform: rotate(0.6deg); box-shadow: 0 1px 0 var(--line), 0 12px 24px rgba(20, 24, 29, 0.08); }
.preview-label { margin: 0 0 12px; font-size: 12px; font-weight: 700; color: var(--muted); }
.preview-bar { display: flex; height: 8px; gap: 4px; margin-bottom: 16px; }
.preview-claim { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.preview-name { font-size: 16px; font-weight: 700; }
.preview-prints { display: flex; gap: 4px; }
.preview-prints i { width: 32px; height: 24px; background: linear-gradient(135deg, #cfd4d8, #aab1b7); border: 2px solid var(--paper); box-shadow: 0 0 0 1px var(--line); }
.preview-prints.empty { width: 68px; height: 28px; border: 1px dashed var(--line); }

/* ── 점검 화면 머리띠 ── */
.board-head { display: flex; flex-wrap: wrap; gap: 24px; justify-content: space-between; align-items: flex-end; margin-top: 16px; }
.board-title-block { min-width: 240px; }
.actions { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; margin: 8px 0 0; }
.scoreboard { display: grid; gap: 12px; min-width: 260px; }
.metrics { display: flex; gap: 32px; }
.metric { margin: 0; display: grid; grid-template-columns: auto auto; column-gap: 4px; align-items: baseline; }
.metric-value { font-size: 40px; font-weight: 800; line-height: 1; letter-spacing: -0.03em; }
.metric-unit { font-size: 14px; color: var(--muted); }
.metric-label { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
.statusbar { display: flex; gap: 4px; height: 8px; background: var(--wash); }
.seg { display: block; min-width: 8px; height: 100%; }
.seg.present { background: var(--ok); } .seg.weak { background: var(--warn); } .seg.none { background: var(--bad); }
.status { min-height: 20px; margin: 12px 0 0; font-size: 14px; font-weight: 600; }
.status.error { color: var(--bad); }

/* ── 작업대: 항목 카드 | 사진 더미 ── */
.workspace { display: grid; gap: 16px; align-items: start; }
.claims { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.claim { position: relative; display: grid; grid-template-columns: 144px 1fr; gap: 16px; padding: 16px; background: var(--paper); border: 1px solid var(--line); border-left: 4px solid var(--line); transition: background 0.15s, outline-color 0.15s; }
.claim.present { border-left-color: var(--ok); } .claim.weak { border-left-color: var(--warn); } .claim.none { border-left-color: var(--bad); }
.claim.drop-ready { outline: 1px dashed var(--ink); outline-offset: -4px; }
.claim.drop-hover { background: var(--wash); outline: 2px solid var(--ink); outline-offset: -4px; }
.stamp-col { display: grid; gap: 8px; justify-items: start; align-content: start; }
.stamp { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; font-weight: 800; letter-spacing: 0.1em; padding: 8px 12px; border: 2px solid currentColor; outline: 1px solid currentColor; outline-offset: 2px; border-radius: 2px; transform: rotate(-4deg); background-image: repeating-linear-gradient(135deg, transparent 0 6px, rgba(255, 255, 255, 0.5) 6px 7px); }
.stamp::before { font-size: 12px; }
.stamp.present { color: var(--ok); } .stamp.present::before { content: "●"; }
.stamp.weak { color: var(--warn); } .stamp.weak::before { content: "▲"; }
.stamp.none { color: var(--bad); } .stamp.none::before { content: "■"; }
.stamp-in { animation: stamp-in 0.45s var(--ease) both; }
@keyframes stamp-in { 0% { transform: rotate(-14deg) scale(1.9); opacity: 0; } 55% { transform: rotate(-4deg) scale(0.92); opacity: 1; } 100% { transform: rotate(-4deg) scale(1); } }
.stamp-sub { font-size: 12px; color: var(--muted); }
.claim-main { min-width: 0; }
.claim-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.claim-name { font-size: 24px; line-height: 1.2; letter-spacing: -0.02em; }
.claim-reason { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.claim-retake { margin: 4px 0 0; font-size: 14px; font-weight: 700; color: var(--ink); }
.prints { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 12px 0; }
.print { display: block; padding: 4px; background: var(--paper); box-shadow: 0 0 0 1px var(--line), 0 2px 4px rgba(20, 24, 29, 0.18); }
.print img { display: block; width: 88px; height: 66px; object-fit: cover; }
.print.weak { box-shadow: 0 0 0 2px var(--warn), 0 2px 4px rgba(20, 24, 29, 0.18); }
.prints .more { font-size: 14px; font-weight: 800; color: var(--muted); }
.prints-empty { margin: 12px 0; padding: 16px; border: 1px dashed var(--line); font-size: 14px; color: var(--muted); text-align: center; }
.assigned { display: flex; gap: 4px; flex-wrap: wrap; margin: 0 0 8px; }
.assigned button { min-height: 28px; padding: 4px 8px; font-size: 12px; font-weight: 600; }
.note-input { font-size: 12px; padding: 4px 8px; }

.tray { background: transparent; }
.stacks { display: grid; gap: 12px; }
.stack { display: grid; gap: 8px; text-align: left; background: var(--paper); border: 1px solid var(--line); border-radius: 2px; padding: 12px; width: 100%; font-weight: 400; min-height: 0; cursor: grab; }
.stack:hover { border-color: var(--ink); }
.stack[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); background: var(--wash); }
.fan { position: relative; display: block; height: 96px; margin: 4px 0 4px 8px; }
.fan img { position: absolute; top: 8px; left: 0; width: 96px; height: 72px; object-fit: cover; border: 4px solid var(--paper); box-shadow: 0 1px 4px rgba(20, 24, 29, 0.4); transition: transform 0.25s var(--ease); }
.fan img:nth-child(1) { transform: rotate(-6deg) translateX(0); z-index: 1; }
.fan img:nth-child(2) { transform: rotate(0deg) translateX(40px); z-index: 2; }
.fan img:nth-child(3) { transform: rotate(6deg) translateX(80px); z-index: 3; }
.stack:hover .fan img:nth-child(1), .stack[aria-pressed="true"] .fan img:nth-child(1) { transform: rotate(-9deg) translateX(-4px); }
.stack:hover .fan img:nth-child(3), .stack[aria-pressed="true"] .fan img:nth-child(3) { transform: rotate(9deg) translateX(92px); }
.stack-info { display: flex; justify-content: space-between; gap: 8px; font-weight: 800; }
.stack-time { font-size: 14px; } .stack-count { font-size: 14px; color: var(--muted); }
.stack-meta { font-size: 12px; color: var(--muted); }
.badge { font-size: 12px; font-weight: 800; color: var(--warn); }
.badge.ok { color: var(--ok); }

.foot { padding-top: 16px; padding-bottom: 32px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); }

@media (min-width: 980px) {
  .start { grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); gap: 32px; margin-top: 32px; }
  .workspace { grid-template-columns: minmax(0, 1fr) 280px; }
  .tray { position: sticky; top: 16px; }
}
@media (max-width: 979px) {
  .tray { order: -1; }
  .stacks { display: flex; overflow-x: auto; gap: 12px; padding-bottom: 8px; }
  .stack { flex: 0 0 220px; width: 220px; }
}
@media (max-width: 640px) {
  .start h2 { font-size: 24px; }
  .claim { grid-template-columns: 1fr; gap: 12px; }
  .claim-top { flex-direction: column; }
  .metrics { gap: 24px; }
  .metric-value { font-size: 40px; }
}

/* 인쇄: 인쇄용 보고만 보인다 */
.print-only { display: none; }
@media print {
  body { background: #fff; }
  .top, main, .foot { display: none !important; }
  .print-only { display: block !important; max-width: none; padding: 0; }
  .print-only h2 { font-size: 24px; margin: 16px 0 8px; }
  .print-only table { width: 100%; border-collapse: collapse; margin: 12px 0; }
  .print-only th, .print-only td { border: 1px solid var(--ink); padding: 4px 8px; text-align: left; vertical-align: top; font-size: 12px; }
  .print-only .disclaimer { margin-top: 16px; padding-top: 8px; border-top: 2px solid var(--ink); font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* 한국어 줄바꿈: 단어 중간에서 끊지 않는다 */
h1, h2, h3, h4, .hint, .steps li, .claim-reason, .claim-retake, .stack-meta, .status, .preview-name { word-break: keep-all; overflow-wrap: break-word; }
.preview-bar .seg { flex: 1 1 0; }
.preview-bar .seg:nth-child(1) { flex-grow: 3; }
.workspace > * { min-width: 0; }
.stacks { max-width: 100%; }

/* 참고 도해: 증거 영역 밖에서만 쓰는 일반 도해(캡션 필수) */
.start-side { display: grid; gap: 16px; align-self: start; min-width: 0; }
.figure { margin: 0; background: var(--paper); border: 1px solid var(--line); padding: 8px; }
.figure img { display: block; width: 100%; height: auto; mix-blend-mode: multiply; }
.figure figcaption { font-size: 12px; color: var(--muted); padding-top: 8px; border-top: 1px solid var(--line); margin-top: 8px; }
.reference summary { cursor: pointer; font-weight: 600; }
.figures { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-top: 16px; }
@media print { .figure, .reference { display: none !important; } }

/* 현장 배치도: 직접 그린 평면도(실측 아님) */
.layout-form, .layout-bar, .tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.layout-form input[type="number"] { width: 96px; }
.tool.active { background: var(--ink); color: var(--paper); }
.plan-wrap { margin: 8px 0; border: 1px solid var(--line); background: var(--paper); }
.plan { display: block; width: 100%; height: auto; max-height: 70vh; }
.plan.interactive { touch-action: none; cursor: crosshair; }
.plan-bg { fill: var(--paper); }
.plan-grid line { stroke: var(--line); stroke-width: 0.3; }
.plan-shape rect { stroke: var(--ink); stroke-width: 0.6; }
.plan-shape.zone rect { fill: var(--wash); stroke: var(--muted); stroke-dasharray: 3 2; }
.plan-shape.wall rect { fill: var(--ink); }
.plan-shape.door rect { fill: var(--paper); }
.plan-shape.box rect { fill: #dfe3e6; }
.plan-shape.selected rect { stroke: var(--warn); stroke-width: 1.2; }
.plan-shape text { fill: var(--ink); }
.plan-preview { fill: rgba(20, 24, 29, 0.12); stroke: var(--ink); stroke-width: 0.5; stroke-dasharray: 2 2; pointer-events: none; }
.plan-pin { cursor: pointer; }
.plan-pin circle { fill: var(--ink); stroke: var(--paper); stroke-width: 0.6; }
.plan-pin text { fill: var(--paper); font-weight: 700; pointer-events: none; }
.plan-pin.selected circle { stroke: var(--warn); stroke-width: 1.4; }
.plan-heading { stroke: var(--ink); stroke-width: 0.9; }
.pin-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.pin-chip.active { outline: 2px solid var(--warn); }
.pin-panel { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--line); background: var(--wash); }
.pin-photos { display: flex; flex-wrap: wrap; gap: 8px; }
.pin-photo { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); background: var(--paper); padding: 4px; }
.pin-photo.missing { border-style: dashed; color: var(--muted); }
.pin-photo-name { font-size: 12px; }
.layout-note { font-weight: 600; }
@media print { #layout-panel { display: none !important; } .plan { max-height: none; } .plan-wrap { break-inside: avoid; } }

.plan-pin .plan-hit { fill: transparent; stroke: none; }
.layout-form input[type="text"] { width: 220px; }
