:root {
  --red:#FF0020; --black:#141414; --gray:#BDBDBD;
  --bg:#fff; --fg:#141414; --muted:#6b6b6b; --line:#e6e6e6; --card:#fafafa; --soft:#fff1f3;
}
@media (prefers-color-scheme: dark) {
  :root { --bg:#0f0f10; --fg:#f2f2f2; --muted:#a0a0a0; --line:#2a2a2d; --card:#18181a; --soft:#2a1216; }
}
* { box-sizing: border-box; }
body { margin:0; background:var(--bg); color:var(--fg); font-family:-apple-system,"Pretendard","Noto Sans KR",sans-serif; line-height:1.6; }
[hidden] { display:none !important; }
button { font:inherit; cursor:pointer; }

/* 브랜드 헤더: 빨강 배경 + 검정 로고 */
.brand { background:var(--red); color:var(--black); padding:18px 16px 14px; }
.brand-inner { max-width:820px; margin:0 auto; }
.home { display:inline-block; }
.home:focus-visible { outline:3px solid var(--black); outline-offset:4px; }
.logo { display:block; width:min(200px,50vw); height:auto; mix-blend-mode:multiply; }
.tagline { margin:10px 0 0; font-weight:800; letter-spacing:.02em; font-size:.95rem; }
.tagline i { font-family:Georgia,serif; font-weight:400; }

main, #login .box { max-width:820px; margin:0 auto; padding:20px 16px 64px; }
.brand-inner { max-width:1180px; }

/* PC: 검색 + 오른쪽 QR 고정 / 모바일: QR 버튼 → 전체 화면 */
.layout { max-width:1180px; margin:0 auto; display:grid; grid-template-columns:minmax(0,1fr) 300px; gap:24px; padding:0 16px; }
.layout main { padding:20px 0 64px; max-width:none; margin:0; min-width:0; }
.facts td { overflow-wrap:anywhere; }
#qrPanel { position:sticky; top:16px; align-self:start; margin-top:20px; border:2px solid var(--black); border-radius:16px; padding:18px; text-align:center; background:var(--bg); }
.qr-title { margin:0 0 10px; font-weight:800; }
.qr-box { background:#fff; border-radius:10px; padding:12px; }
#qrCode svg, #qrCodeBig svg { width:100%; height:auto; display:block; }
.qr-label { margin:10px 0 2px; font-weight:800; font-size:1.05rem; }
.qr-url { margin:0; font-size:.78rem; color:var(--muted); word-break:break-all; }
.qr-actions { display:flex; gap:8px; margin-top:12px; }
.qr-actions button { flex:1; border:1px solid var(--line); background:var(--bg); color:var(--fg); border-radius:8px; padding:7px; font-size:.85rem; }
.qr-btn { border:1px solid var(--black); background:var(--bg); color:var(--fg); border-radius:999px; padding:2px 10px; font-size:.78rem; font-weight:700; margin-left:6px; vertical-align:middle; }
#qrFab { position:fixed; right:16px; bottom:16px; z-index:5; width:60px; height:60px; border-radius:50%; border:0; background:var(--red); color:#fff; font-weight:800; box-shadow:0 4px 14px rgba(0,0,0,.25); }
#qrModal { position:fixed; inset:0; z-index:12; background:#fff; color:#141414; display:flex; align-items:center; justify-content:center; padding:24px; }
.qr-modal-inner { width:min(86vw,520px); text-align:center; }
.qr-hint { color:#6b6b6b; margin:4px 0 0; }
#qrModal > button { position:fixed; top:12px; right:12px; background:#141414; color:#fff; border:0; border-radius:999px; width:44px; height:44px; font-size:1.2rem; }
@media (max-width: 900px) {
  .layout { grid-template-columns:minmax(0,1fr); padding:0; }
  .layout main { padding:20px 16px 96px; }
  #qrPanel { display:none; }
}
@media (min-width: 901px) { #qrFab { display:none; } }
.sub { margin:0 0 14px; color:var(--muted); }
input[type=search], input[type=password] { width:100%; padding:15px 16px; font-size:1.05rem; border:2px solid var(--black); border-radius:12px; background:var(--bg); color:var(--fg); }
@media (prefers-color-scheme: dark) { input[type=search], input[type=password] { border-color:var(--gray); } }
input:focus { outline:3px solid var(--red); outline-offset:1px; }
.sticky { position:sticky; top:0; background:var(--bg); padding:12px 0 4px; z-index:2; }

#login .box form { display:grid; gap:12px; margin-top:24px; }
#login button { padding:13px; border:0; border-radius:12px; background:var(--black); color:#fff; font-weight:700; }
#loginErr { color:var(--red); margin:0; min-height:1.5em; }

#chips { display:flex; flex-wrap:wrap; gap:6px; margin:10px 0 4px; }
#chips button { border:1px solid var(--line); background:var(--bg); color:var(--fg); padding:5px 12px; border-radius:999px; font-size:.88rem; }
#chips button.on { background:var(--black); border-color:var(--black); color:#fff; }
@media (prefers-color-scheme: dark) { #chips button.on { background:var(--red); border-color:var(--red); } }
#count { color:var(--muted); font-size:.85rem; margin:6px 0; }
#results { display:grid; grid-template-columns:minmax(0,1fr); gap:14px; }
.card { min-width:0; }

.card { background:var(--card); border:1px solid var(--line); border-radius:14px; padding:16px; }
.card.top { border:2px solid var(--red); }
.tag { display:inline-block; font-size:.75rem; font-weight:700; color:#fff; background:var(--red); padding:1px 8px; border-radius:4px; }
.card h2 { margin:8px 0 10px; font-size:1.08rem; }

.facts { width:100%; border-collapse:collapse; margin:0 0 10px; font-size:.95rem; }
.facts th { text-align:left; vertical-align:top; white-space:nowrap; padding:6px 12px 6px 0; color:var(--muted); font-weight:600; width:1%; }
.facts td { padding:6px 0; font-weight:600; }
.facts tr + tr th, .facts tr + tr td { border-top:1px solid var(--line); }

.tbl { margin:4px 0 14px; }
.tbl h3 { margin:0 0 6px; font-size:.85rem; color:var(--muted); }
details.tbl summary { cursor:pointer; font-size:.85rem; font-weight:700; color:var(--red); margin-bottom:6px; }
/* 1순위 결과의 첫 줄은 바로 읽히도록 크게 */
.card.top .facts tr:first-child th { font-size:.95rem; color:var(--fg); }
.card.top .facts tr:first-child td { font-size:1.2rem; font-weight:800; color:var(--red); }
.tscroll { overflow-x:auto; border:1px solid var(--line); border-radius:10px; }
.tbl table { width:100%; border-collapse:collapse; font-size:.92rem; }
.tbl thead th { background:var(--black); color:#fff; text-align:left; padding:8px 10px; white-space:nowrap; font-weight:700; }
.tbl td { padding:8px 10px; border-top:1px solid var(--line); vertical-align:top; }
.tbl td:first-child { font-weight:700; white-space:nowrap; }
.tbl tbody tr:nth-child(even) { background:rgba(127,127,127,.06); }
.note { margin:0 0 10px; padding:8px 12px; border-left:3px solid var(--red); background:var(--soft); font-size:.88rem; white-space:pre-wrap; }
.answer { margin:0; white-space:pre-wrap; color:var(--fg); }
.maps { display:grid; grid-template-columns:repeat(auto-fill,minmax(160px,1fr)); gap:8px; margin-top:12px; }
.maps img { width:100%; height:120px; object-fit:cover; border-radius:8px; border:1px solid var(--line); cursor:zoom-in; display:block; }
.card.top .maps { grid-template-columns:1fr; }
.card.top .maps img { height:auto; max-height:420px; object-fit:contain; background:var(--soft); }

details.script { margin-top:12px; border-radius:8px; background:var(--soft); padding:8px 12px; }
details.script summary { cursor:pointer; font-size:.85rem; font-weight:700; color:var(--red); }
details.script p { margin:8px 0 0; white-space:pre-wrap; }
.copy { margin-top:8px; border:1px solid var(--line); background:var(--bg); color:var(--fg); border-radius:8px; padding:4px 10px; font-size:.85rem; }
.src { font-size:.75rem; color:var(--muted); margin-top:10px; }

.contact { display:flex; flex-wrap:wrap; align-items:center; justify-content:center; gap:6px 12px; background:var(--black); color:#fff; border:0; }
.contact .clabel { font-size:.75rem; font-weight:800; background:var(--red); padding:2px 8px; border-radius:4px; }
.contact .cname { font-weight:700; }
.contact .cphone { color:#fff; font-weight:800; font-size:1.05rem; text-decoration:underline; text-underline-offset:3px; }
.empty { text-align:center; color:var(--muted); }
mark { background:rgba(255,0,32,.18); color:inherit; border-radius:2px; }

#viewer { position:fixed; inset:0; background:rgba(0,0,0,.88); display:flex; align-items:center; justify-content:center; z-index:10; overflow:auto; padding:16px; }
#viewer img { max-width:100%; max-height:100%; object-fit:contain; }
#viewer button { position:fixed; top:12px; right:12px; background:#fff; border:0; border-radius:999px; width:40px; height:40px; font-size:1.2rem; }
