:root {
  --ink: #141414;
  --sub: #6d6d6a;
  --paper: #f4f4f1;
  --line: #d6d6d2;
  --font: "Noto Sans KR", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; -webkit-user-select: none; user-select: none; background: #dededa; color: var(--ink); font-family: var(--font); font-weight: 400; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: default; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
[hidden] { display: none !important; }

#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.lb { position: absolute; left: 0; top: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; white-space: nowrap; will-change: transform; }
.lb .n { font-size: 11px; letter-spacing: .02em; color: #444; }
.lb.me .n { color: #000; font-weight: 500; }
.lb .b { max-width: 220px; white-space: normal; word-break: break-all; font-size: 13px; padding: 5px 10px; background: #fff; border: 1px solid var(--ink); opacity: 0; transition: opacity .18s; }
.lb .b.on { opacity: 1; }

#tip { position: fixed; left: 0; top: 0; padding: 5px 9px; background: var(--ink); color: #fff; font-size: 12px; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .12s; }
#tip.on { opacity: 1; }

#hud { position: fixed; top: max(16px, env(safe-area-inset-top)); left: 18px; right: 18px; display: flex; justify-content: space-between; align-items: flex-start; pointer-events: none; }
#hud img { height: 22px; display: block; }
.hudRight { display: flex; align-items: flex-start; gap: 12px; pointer-events: auto; }
.hudRight .count { line-height: 28px; }
.hudBtns { display: flex; flex-direction: column; gap: 6px; }
#inquiry { padding: 6px 10px; background: var(--ink); color: #fff; border: 1px solid var(--ink); font-size: 12px; white-space: nowrap; }
#inquirySheet { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(20, 20, 20, .45); }
#inquirySheet .card { position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; width: min(320px, 100%); padding: 34px 24px 24px; background: var(--paper); text-align: center; }
#inquirySheet h2 { margin: 0; font-size: 16px; font-weight: 500; }
#inquirySheet p { margin: 0; font-size: 13px; color: var(--sub); }
#inquirySheet .card { width: min(420px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; align-items: stretch; text-align: left; }
#inquiryForm { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
#inquiryForm label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: #333; }
#inquiryForm input[type=text], #inquiryForm textarea { width: 100%; padding: 9px 10px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-size: 14px; -webkit-user-select: text; user-select: text; }
#inquiryForm textarea { min-height: 110px; resize: vertical; }
#inquiryForm .agree { flex-direction: row; align-items: flex-start; gap: 7px; font-size: 11px; color: var(--sub); line-height: 1.5; }
#inquiryForm .trap { position: absolute; left: -9999px; }
#inquirySend { padding: 11px; background: var(--ink); color: #fff; font-size: 13px; }
#inquirySend:disabled { opacity: .5; cursor: default; }
#inquiryMsg { min-height: 16px; font-size: 12px; color: #a22; }
#inquiryMsg.ok { color: #1c6b3a; }
#inquiryClose { position: absolute; top: 12px; right: 14px; font-size: 12px; text-decoration: underline; text-underline-offset: 3px; }
.count { font-size: 12px; color: #333; letter-spacing: .02em; }
#music { display: flex; align-items: center; gap: 6px; padding: 6px 10px; background: #fff; border: 1px solid var(--ink); font-size: 12px; white-space: nowrap; }
.eq { display: flex; align-items: flex-end; gap: 2px; width: 12px; height: 12px; }
.eq i { flex: 1; height: 100%; background: var(--ink); transform: scaleY(.15); transform-origin: bottom; }

#hint { position: fixed; bottom: calc(max(16px, env(safe-area-inset-bottom)) + 58px); left: 50%; transform: translateX(-50%); font-size: 12px; color: #333; pointer-events: none; white-space: nowrap; transition: opacity .6s; }
#toast { position: fixed; top: 16%; left: 50%; transform: translateX(-50%); padding: 9px 16px; background: var(--ink); color: #fff; font-size: 13px; opacity: 0; transition: opacity .25s; pointer-events: none; white-space: nowrap; }
#toast.on { opacity: 1; }

#actions { position: fixed; bottom: max(16px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); display: flex; background: #fff; border: 1px solid var(--ink); }
#actions button { width: 84px; height: 40px; font-size: 13px; }
#actions button + button { border-left: 1px solid var(--ink); }
#actions button.on { background: var(--ink); color: #fff; }

#chat { position: fixed; left: 50%; bottom: calc(max(16px, env(safe-area-inset-bottom)) + 52px + var(--kb, 0px)); transform: translateX(-50%); display: flex; width: min(420px, calc(100vw - 32px)); background: #fff; border: 1px solid var(--ink); }
#chat input { flex: 1; min-width: 0; padding: 10px 12px; border: 0; border-radius: 0; background: #fff; color: var(--ink); font: inherit; font-size: 16px; outline: 0; -webkit-user-select: text; user-select: text; }
#chat button { padding: 0 14px; border-left: 1px solid var(--ink); font-size: 13px; white-space: nowrap; }

#logWrap { position: fixed; left: 18px; top: 58px; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; width: min(280px, calc(100vw - 36px)); }
#log { width: 100%; height: 150px; overflow-y: auto; padding: 8px 10px; background: rgba(255, 255, 255, .72); overscroll-behavior: contain; touch-action: pan-y; scrollbar-width: thin; }
#log.closed { display: none; }
#logBox { display: flex; flex-direction: column; gap: 4px; }
#logBox:empty::before { content: "아직 대화가 없어요"; color: var(--sub); font-size: 12px; }
#logBox > div { font-size: 13px; line-height: 1.4; word-break: break-all; }
#logBox b { margin-right: 6px; font-weight: 500; }
#logBox button { margin-left: 6px; color: var(--sub); font-size: 11px; white-space: nowrap; }
#logToggle { font-size: 11px; color: #333; }

#detail { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(20, 20, 20, .45); }
.sheet { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 280px; width: min(920px, 100%); max-height: calc(100dvh - 32px); background: var(--paper); overflow: hidden; }
#close { position: absolute; top: 14px; right: 16px; z-index: 2; font-size: 12px; text-decoration: underline; text-underline-offset: 3px; }
#book { position: fixed; inset: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; place-items: center; gap: 10px; padding: 44px 16px 14px; background: #141414; color: #fff; }
#bookClose { position: absolute; top: 12px; right: 14px; padding: 4px 6px; font-size: 12px; text-decoration: underline; text-underline-offset: 3px; }
#spread { display: flex; justify-content: center; gap: 2px; height: 100%; min-height: 0; max-width: 100%; touch-action: pan-y; cursor: pointer; }
#spread img { display: block; height: 100%; max-width: 100%; min-width: 0; object-fit: contain; -webkit-user-drag: none; }
#spread img + img { max-width: 50%; }
#spread img:has(+ img) { max-width: 50%; }
#bookBar { display: flex; align-items: center; gap: 14px; font-size: 12px; }
#bookBar button { width: 44px; height: 36px; font-size: 22px; line-height: 1; color: #fff; }
#bookBar button:disabled { opacity: .3; cursor: default; }
#bookCount { min-width: 64px; text-align: center; }
.gallery { min-width: 0; display: flex; flex-direction: column; background: #fff; }
#main { display: block; width: 100%; height: min(70dvh, 620px); object-fit: contain; background: #efefec; }
#thumbs { display: flex; gap: 4px; padding: 6px; overflow-x: auto; }
#thumbs button { flex: none; width: 56px; height: 74px; padding: 0; opacity: .55; }
#thumbs button.on { opacity: 1; outline: 1px solid var(--ink); outline-offset: -1px; }
#thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
.info { display: flex; flex-direction: column; padding: 48px 24px 24px; }
#dNo { margin: 0 0 8px; font-size: 11px; color: var(--sub); letter-spacing: .08em; }
#dName { margin: 0; font-size: 18px; font-weight: 500; line-height: 1.35; }
#dPrice { margin: 10px 0 0; font-size: 14px; }
#dBuy { margin-top: auto; padding: 13px; background: var(--ink); color: #fff; text-align: center; text-decoration: none; font-size: 13px; }

#intro { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(244, 244, 241, .7); }
.card { display: flex; flex-direction: column; align-items: center; }
.card img { width: 150px; }
.card p { margin: 14px 0 28px; font-size: 13px; color: #333; letter-spacing: .04em; }
.streetName { display: none; font-family: Georgia, "Times New Roman", serif; font-weight: 500; font-size: 17px; letter-spacing: .14em; color: var(--ink); }
.card p.streetName { font-family: var(--font); font-size: 13px; letter-spacing: .04em; color: #333; }
.streetName.big { font-size: 30px; }
body.street .streetName { display: block; }
body.street .afehOnly, body.street #hud .afehOnly { display: none; }
.privacy { margin-top: 14px; font-size: 11px; color: var(--sub); text-align: center; }
#enter { padding: 11px 44px; background: var(--ink); color: #fff; font-size: 13px; letter-spacing: .08em; }

@media (max-width: 760px) {
  .sheet { grid-template-columns: 1fr; overflow-y: auto; }
  #main { height: 56dvh; }
  .info { padding: 14px 16px 16px; }
  #dBuy { margin-top: 16px; }
  #close { top: 10px; right: 12px; padding: 4px 6px; background: rgba(255, 255, 255, .8); }
  #log { height: 96px; }
  #logWrap { width: min(220px, calc(100vw - 36px)); }
}
@media (max-height: 520px) {
  #log { height: 72px; }
  .sheet { grid-template-columns: minmax(0, 1fr) 240px; }
  #main { height: 62dvh; }
  .info { padding: 40px 16px 16px; }
}
