:root {
  --bg: #f6f5f2;
  --card: #ffffff;
  --text: #1d1d1b;
  --muted: #6b6a65;
  --line: #dddbd4;
  --accent: #1f6f4a;
  --accent-text: #ffffff;
  --call: #1f6f4a;
  --danger: #b3261e;
  --warn-bg: #fff4d6;
  --tab-h: 64px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413;
    --card: #1f1f1d;
    --text: #ecebe6;
    --muted: #a3a29c;
    --line: #34332f;
    --accent: #3fa776;
    --accent-text: #0d1f16;
    --call: #3fa776;
    --danger: #ef6b62;
    --warn-bg: #3a3218;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 18px/1.5 system-ui, -apple-system, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 16px);
  /* 한글이 낱말 중간(「밸브부/터」)에서 끊기지 않게. 긴 파일 이름은 그래도 넘치지 않고 꺾인다. */
  word-break: keep-all;
  overflow-wrap: anywhere;
}
a { color: inherit; }

.top { padding: 12px 16px 0; max-width: 640px; margin: 0 auto; }
.brand { font-weight: 700; text-decoration: none; color: var(--muted); font-size: 15px; }
main { max-width: 640px; margin: 0 auto; padding: 0 16px; }
h1 { font-size: 28px; margin: 8px 0 16px; }
h2 { font-size: 15px; color: var(--muted); margin: 20px 0 8px; font-weight: 600; }
.sub { color: var(--muted); font-size: 15px; }
.empty { color: var(--muted); }
.err { color: var(--danger); min-height: 1em; margin: 4px 0; }
.warn { background: var(--warn-bg); padding: 12px; border-radius: 10px; font-size: 15px; }

/* 아래 탭 — 엄지가 닿는 자리 */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  flex: 1; height: var(--tab-h); display: flex; align-items: center; justify-content: center;
  text-decoration: none; color: var(--muted); font-weight: 600;
}
.tabs a.on { color: var(--accent); }

/* 전화번호부 */
ul { list-style: none; margin: 0; padding: 0; }
.contacts li, .items li {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 8px;
}
.contacts li { display: flex; align-items: stretch; }
.who { flex: 1; min-width: 0; padding: 14px 16px; text-decoration: none; display: flex; flex-direction: column; justify-content: center; }
.name { font-weight: 700; font-size: 20px; }
.memo { color: var(--muted); font-size: 15px; }
.call {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 132px; padding: 10px 12px; background: var(--call); color: var(--accent-text);
  border-radius: 0 13px 13px 0; text-decoration: none;
}
.call .num { font-size: 15px; font-variant-numeric: tabular-nums; }
.call .go { font-size: 20px; font-weight: 800; }

/* 시설물 */
.search {
  width: 100%; font: inherit; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
}
.items a { display: flex; flex-direction: column; padding: 14px 16px; text-decoration: none; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.tag { display: inline-block; font-size: 14px; padding: 2px 10px; border-radius: 99px; border: 1px solid var(--line); }
.tag.off { color: var(--danger); border-color: var(--danger); }
.memo-box { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; white-space: pre-wrap; }
.files li { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.files a { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; text-decoration: none; }
.files img, .files .pdf { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); flex: none; }
.files .pdf { display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--danger); }
.fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.x { font: inherit; font-size: 15px; background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 8px; padding: 6px 10px; }
.qr-one .qr { width: 180px; background: #fff; padding: 8px; border-radius: 8px; }
.qr svg { display: block; width: 100%; height: auto; }

/* 폼·버튼 */
.form label { display: block; margin-bottom: 14px; font-size: 15px; color: var(--muted); }
.form input, .form select, .form textarea {
  display: block; width: 100%; margin-top: 4px; font: inherit; font-size: 18px; color: var(--text);
  padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 52px; padding: 0 20px;
  font: inherit; font-weight: 700; border-radius: 14px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); text-decoration: none; cursor: pointer;
}
.btn.wide { width: 100%; margin-top: 8px; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }

/* 스티커 */
.pick li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.pick input { width: 22px; height: 22px; vertical-align: middle; margin-right: 8px; }
.sheet { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.sticker {
  background: #fff; color: #000; border: 1px dashed #999; border-radius: 6px;
  padding: 8px; display: flex; flex-direction: column; align-items: center; text-align: center;
}
.sticker .qr { width: 100%; max-width: 140px; }
.sticker .label { display: flex; flex-direction: column; font-size: 13px; line-height: 1.3; }
.sticker .label b { font-size: 15px; }
.sticker .id { color: #666; font-size: 11px; letter-spacing: 1px; }

@media print {
  @page { size: A4; margin: 10mm; }
  body { background: #fff; padding: 0; }
  .top, .tabs, .no-print { display: none !important; }
  main { max-width: none; padding: 0; }
  .sheet { grid-template-columns: repeat(3, 60mm); grid-auto-rows: 52mm; gap: 3mm; margin: 0; }
  .sticker { break-inside: avoid; border-radius: 0; height: 52mm; padding: 2mm; }
  .sticker .qr { width: 36mm; }
}
