:root {
  --brand: #2E6B4F;
  --brand-2: #3f8a67;
  --ink: #161917;
  --ink-2: #4b524e;
  --muted: #868d89;
  --line: rgba(20, 30, 25, .1);
  --paper: #fbfaf7;
  --glass: rgba(255, 255, 255, .78);
  --shadow: 0 10px 40px rgba(16, 24, 20, .16), 0 2px 8px rgba(16, 24, 20, .08);
  --r: 18px;
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; font-family: var(--font); color: var(--ink); background: #121614; letter-spacing: -0.01em; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
small { font-size: .82em; }
kbd { font: 600 11px/1 var(--font); padding: 4px 6px; border-radius: 6px; background: rgba(0,0,0,.07); border: 1px solid rgba(0,0,0,.08); border-bottom-width: 2px; }

/* ── 갤러리 페이지 ── */
body.gallery { overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
.glass { background: var(--glass); backdrop-filter: blur(16px) saturate(1.4); -webkit-backdrop-filter: blur(16px) saturate(1.4); box-shadow: var(--shadow); border: 1px solid rgba(255,255,255,.6); }
body[data-theme="attic"] .glass { background: rgba(255, 250, 242, .82); }

#loading { position: fixed; inset: 0; z-index: 50; display: grid; place-content: center; justify-items: center; gap: 22px; background: radial-gradient(circle at 50% 40%, #232a26, #0e1110); color: #e9ece9; transition: opacity .6s ease; }
#loading.done { opacity: 0; pointer-events: none; }
#loading p { margin: 0; font-size: 14px; letter-spacing: .02em; opacity: .8; text-align: center; line-height: 1.7; }
#loading a { color: #9fd7b8; }
.loader-frame { width: 72px; height: 90px; border: 4px solid #e9ece9; padding: 7px; border-radius: 2px; }
.loader-frame span { display: block; height: 100%; background: linear-gradient(110deg, #2e6b4f 0%, #81b29a 40%, #e9b949 60%, #2e6b4f 100%); background-size: 300% 100%; animation: shimmer 1.6s linear infinite; }
@keyframes shimmer { to { background-position: -300% 0; } }

.overlay { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 20px; background: rgba(12, 16, 14, .38); opacity: 0; transition: opacity .2s ease; }
#enter.overlay { opacity: 1; background: linear-gradient(180deg, rgba(12,16,14,0) 30%, rgba(12,16,14,.55)); align-items: end; padding-bottom: calc(28px + var(--safe-b)); }
.overlay.show { opacity: 1; }
.card { background: var(--paper); border-radius: 24px; box-shadow: 0 30px 80px rgba(0,0,0,.35); width: min(440px, 100%); padding: 26px; }
.enter-card { animation: rise .6s cubic-bezier(.2,.9,.2,1) both; }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .14em; color: var(--brand); text-transform: uppercase; }
.enter-card h1 { margin: 8px 0 4px; font-size: 28px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.2; }
.enter-card > p { margin: 0 0 20px; font-size: 14px; }
.field { display: grid; gap: 8px; margin: 0 0 16px; }
.field > span { font-size: 13px; font-weight: 700; color: var(--ink-2); }
input:not([type]), input[type="text"], textarea {
  width: 100%; padding: 13px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff; outline: none; transition: border-color .15s, box-shadow .15s; font-size: 15px;
}
input:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(46,107,79,.12); }
textarea { resize: none; line-height: 1.55; }
.swatches { display: flex; gap: 9px; flex-wrap: wrap; }
.swatches button { width: 32px; height: 32px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 2px rgba(255,255,255,.5); transition: transform .15s; }
.swatches button.on { box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--c); transform: scale(1.06); }
.hint { margin: 14px 0 0; text-align: center; font-size: 12px; color: var(--muted); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 46px; padding: 0 20px; border-radius: 14px; font-weight: 700; font-size: 15px; transition: transform .12s, background .15s, opacity .15s; white-space: nowrap; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; pointer-events: none; }
.btn.primary { background: var(--brand); color: #fff; box-shadow: 0 6px 18px rgba(46,107,79,.32); }
.btn.primary:hover { background: var(--brand-2); }
.btn.ghost { background: rgba(20,30,25,.06); }
.btn.ghost:hover { background: rgba(20,30,25,.1); }
.btn.danger { color: #c0392b; }
.btn.wide { width: 100%; }

/* HUD */
#hud { position: fixed; top: calc(14px + var(--safe-t)); left: 14px; right: 14px; z-index: 10; display: flex; justify-content: space-between; align-items: flex-start; pointer-events: none; }
#hud > * { pointer-events: auto; }
.hud-left { display: grid; gap: 8px; justify-items: start; max-width: min(62vw, 460px); position: relative; }
.title-chip { display: flex; align-items: center; gap: 10px; padding: 7px 7px 7px 16px; border-radius: 999px; font-weight: 800; font-size: 15px; max-width: 100%; }
.title-chip #hudTitle { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { font-size: 11px; font-weight: 800; color: #fff; background: var(--brand); padding: 3px 8px; border-radius: 999px; flex: none; }
.online { display: flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 999px; background: rgba(46,107,79,.1); color: var(--brand); font-weight: 800; font-size: 13px; flex: none; }
.online i { width: 7px; height: 7px; border-radius: 50%; background: #27c26c; box-shadow: 0 0 0 3px rgba(39,194,108,.22); animation: pulse 2s infinite; }
body.offline .online i { background: #c0392b; box-shadow: none; animation: none; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(39,194,108,0); } }
.pop { position: absolute; top: 50px; left: 0; min-width: 200px; padding: 12px; border-radius: 16px; z-index: 2; }
.pop-title { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.person { display: flex; align-items: center; gap: 8px; padding: 6px 2px; font-weight: 600; font-size: 14px; }
.person i { width: 14px; height: 14px; border-radius: 50%; }
.person small { color: var(--brand); font-weight: 800; }
#feed { display: grid; gap: 6px; justify-items: start; }
.feed-line { padding: 7px 13px; border-radius: 12px; font-size: 13px; line-height: 1.4; max-width: 100%; animation: feedIn .35s ease both; transition: opacity 1s; }
.feed-line.fade { opacity: 0; }
@keyframes feedIn { from { transform: translateX(-10px); opacity: 0; } }
.hud-right { display: flex; gap: 8px; }
.icon-btn { position: relative; display: grid; justify-items: center; gap: 2px; width: 58px; padding: 9px 0 7px; border-radius: 16px; font-size: 11px; font-weight: 700; color: var(--ink-2); transition: transform .12s; }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn em { position: absolute; top: 4px; right: 6px; font-style: normal; font-size: 10px; background: #e07a5f; color: #fff; border-radius: 999px; padding: 1px 5px; min-width: 16px; }
.icon-btn em:empty { display: none; }

.prompt { position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%); z-index: 10; display: flex; align-items: center; gap: 10px; padding: 11px 20px 11px 12px; border-radius: 999px; font-weight: 800; font-size: 15px; animation: promptIn .25s ease both; max-width: 82vw; }
.prompt span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prompt kbd { background: var(--brand); color: #fff; border-color: transparent; font-size: 12px; padding: 5px 8px; }
body.touch .prompt kbd { display: none; }
body.touch .prompt { padding: 14px 22px; background: var(--brand); color: #fff; left: auto; right: 16px; transform: none; bottom: calc(96px + var(--safe-b)); animation: none; max-width: 52vw; border-color: transparent; }
@keyframes promptIn { from { transform: translate(-50%, 10px); opacity: 0; } }

#bottom { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; padding: 0 14px calc(14px + var(--safe-b)); display: flex; justify-content: center; align-items: flex-end; pointer-events: none; }
#bottom > * { pointer-events: auto; }
.chatbar { display: flex; align-items: center; gap: 6px; padding: 6px; border-radius: 18px; width: min(560px, 100%); }
.emotes { display: flex; }
.emotes button { width: 38px; height: 40px; border-radius: 12px; font-size: 20px; transition: transform .12s, background .12s; }
.emotes button:hover { background: rgba(0,0,0,.05); }
.emotes button:active { transform: scale(1.3); }
#chatForm { flex: 1; }
#chatInput { padding: 10px 14px; border-radius: 12px; background: rgba(255,255,255,.9); font-size: 14px; border-width: 1px; }
#joy { display: none; position: absolute; left: 22px; bottom: calc(82px + var(--safe-b)); width: 120px; height: 120px; border-radius: 50%; background: rgba(255,255,255,.22); border: 1.5px solid rgba(255,255,255,.55); backdrop-filter: blur(6px); touch-action: none; }
#joy .knob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px; border-radius: 50%; background: rgba(255,255,255,.92); box-shadow: 0 6px 18px rgba(0,0,0,.25); transition: transform .06s; }
body.touch #joy { display: block; }
body.touch .chatbar { width: auto; flex: 1; margin-left: 0; }
body.touch #bottom { justify-content: flex-end; }
body.touch .emotes button { width: 34px; }

#toast { position: fixed; left: 50%; top: calc(76px + var(--safe-t)); transform: translate(-50%, -12px); z-index: 60; background: rgba(20,24,22,.9); color: #fff; padding: 11px 18px; border-radius: 999px; font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none; transition: all .25s ease; max-width: 88vw; text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 모달 */
.modal-card { max-height: min(86vh, 760px); overflow: auto; transform: translateY(12px) scale(.98); transition: transform .22s cubic-bezier(.2,.9,.2,1); width: min(480px, 100%); }
.overlay.show .modal-card { transform: none; }
.m-head { margin-bottom: 18px; }
.m-head h2 { margin: 0 0 4px; font-size: 22px; font-weight: 800; letter-spacing: -0.03em; }
.m-head .muted { font-size: 13px; }
.m-actions { display: flex; gap: 8px; margin-top: 6px; align-items: center; }
.grow { flex: 1; }
.tabs { display: flex; gap: 4px; background: rgba(20,30,25,.06); padding: 4px; border-radius: 12px; margin-bottom: 12px; }
.tabs button { flex: 1; height: 36px; border-radius: 9px; font-weight: 700; font-size: 14px; color: var(--muted); }
.tabs button.on { background: #fff; color: var(--ink); box-shadow: 0 2px 6px rgba(0,0,0,.08); }
.drop { position: relative; display: grid; place-items: center; height: 210px; border-radius: 16px; border: 2px dashed rgba(46,107,79,.35); background: repeating-conic-gradient(#f3f1ec 0 25%, #fbfaf7 0 50%) 0 0 / 22px 22px; cursor: pointer; overflow: hidden; margin-bottom: 12px; transition: border-color .15s, background-color .15s; }
.drop.over { border-color: var(--brand); }
.drop.busy::after { content: "처리 중…"; position: absolute; inset: 0; display: grid; place-items: center; background: rgba(255,255,255,.75); font-weight: 700; }
.drop img { max-width: 100%; max-height: 100%; object-fit: contain; box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.drop-empty { text-align: center; display: grid; gap: 6px; padding: 20px; }
.drop-empty b { font-size: 15px; }
.drop-empty small { color: var(--muted); }
.url-row { display: flex; gap: 8px; margin-bottom: 12px; }
.url-row .btn { height: auto; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { padding: 8px 13px; border-radius: 999px; background: rgba(20,30,25,.06); font-weight: 700; font-size: 13px; color: var(--ink-2); }
.chips button.on { background: var(--brand); color: #fff; }
.frames-pick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.frames-pick button { display: grid; justify-items: center; gap: 6px; padding: 10px 0; border-radius: 12px; font-size: 12px; font-weight: 700; color: var(--ink-2); border: 1.5px solid var(--line); }
.frames-pick button.on { border-color: var(--brand); color: var(--brand); background: rgba(46,107,79,.06); }
.frames-pick i { width: 34px; height: 26px; border: 4px solid; background: #fff; box-shadow: inset 0 0 0 4px #f3efe6; }
.fs-black i { border-color: #151515; } .fs-white i { border-color: #e9e7e2; } .fs-oak i { border-color: #a9784a; } .fs-gold i { border-color: #c59a45; }

.gb-form { display: grid; gap: 10px; margin-bottom: 18px; }
.gb-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.gb-list { display: grid; gap: 10px; }
.gb-item { padding: 14px 16px; border-radius: 14px; background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--c); }
.gb-item header { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.gb-item time { color: var(--muted); }
.gb-item p { margin: 0; font-size: 15px; line-height: 1.6; word-break: keep-all; overflow-wrap: anywhere; }
.empty { text-align: center; padding: 30px 0; color: var(--muted); line-height: 1.7; }
.copy-row { display: flex; gap: 8px; margin-bottom: 10px; }
.copy-row input { font-size: 13px; }
.copy-row .btn { height: auto; }
.owner-box { margin-top: 18px; padding: 16px; border-radius: 14px; background: #fff7e6; border: 1px solid #f3dfb2; }
.owner-box p { margin: 4px 0 10px; font-size: 13px; }
.theme-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.theme-pick button { text-align: left; padding: 10px; border-radius: 16px; border: 2px solid var(--line); display: grid; gap: 2px; }
.theme-pick button.on { border-color: var(--brand); }
.theme-pick b { font-size: 15px; margin-top: 8px; }
.theme-pick small { color: var(--muted); }
.tp { height: 96px; border-radius: 10px; position: relative; overflow: hidden; }
.tp-cube { background: linear-gradient(#f6f5f1 0 66%, #cfccc6 66%); }
.tp-cube::before, .tp-cube::after { content: ""; position: absolute; top: 22%; width: 22%; height: 34%; background: linear-gradient(135deg, #81b29a, #3d5a80); outline: 3px solid #151515; outline-offset: 0; box-shadow: 0 0 0 4px #fff inset; }
.tp-cube::before { left: 18%; } .tp-cube::after { right: 18%; background: linear-gradient(135deg, #e9b949, #e07a5f); }
.tp-attic { background: linear-gradient(#2a1d13, #3b2818 60%, #8e5c38 60%); }
.tp-attic::before { content: ""; position: absolute; inset: 0; background: conic-gradient(from 180deg at 50% 0%, transparent 0 60deg, #b07a4b 60deg 62deg, transparent 62deg 298deg, #b07a4b 298deg 300deg, transparent 300deg); }
.tp-attic::after { content: ""; position: absolute; left: 50%; top: 18%; width: 22px; height: 22px; margin-left: -11px; border-radius: 50%; background: #bcd2ff; box-shadow: 0 0 22px 6px rgba(255,200,120,.45), -40px 30px 0 -6px #ffd58f, 40px 30px 0 -6px #ffd58f; }
.help { list-style: none; padding: 0; margin: 0 0 14px; display: grid; gap: 10px; font-size: 14px; line-height: 1.5; }
.help li { padding-left: 18px; position: relative; }
.help li::before { content: "•"; position: absolute; left: 4px; color: var(--brand); }
.help li.t { display: none; }
body.touch .help li.t { display: block; }
.help li.own { background: rgba(46,107,79,.07); padding: 10px 12px 10px 28px; border-radius: 10px; }
.help li.own::before { left: 12px; top: 10px; }

/* 감상 뷰어 */
.viewer { position: fixed; inset: 0; z-index: 40; background: rgba(10,12,11,.92); display: grid; place-items: center; padding: 56px 20px calc(20px + var(--safe-b)); opacity: 0; transition: opacity .18s ease; overflow: auto; }
.viewer.show { opacity: 1; }
.v-figure { margin: 0; display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 32px; align-items: center; width: min(1200px, 100%); max-height: 100%; color: #eef0ee; }
.v-img { display: grid; place-items: center; min-height: 0; }
.v-img img { max-width: 100%; max-height: calc(100vh - 120px); object-fit: contain; border: 12px solid #fbfaf7; box-shadow: 0 30px 80px rgba(0,0,0,.6); animation: zoomIn .35s cubic-bezier(.2,.9,.2,1) both; }
@keyframes zoomIn { from { transform: scale(.96); opacity: 0; } }
.v-meta { display: flex; gap: 10px; align-items: center; font-size: 13px; color: #a6aea9; }
.chip { padding: 4px 10px; border-radius: 999px; background: rgba(129,178,154,.2); color: #a9e0c3; font-weight: 700; }
figcaption h2 { font-size: 28px; font-weight: 800; letter-spacing: -0.03em; margin: 12px 0 10px; line-height: 1.25; }
figcaption p { font-size: 15px; line-height: 1.75; color: #c9cfcb; margin: 0 0 22px; word-break: keep-all; white-space: normal; }
.v-actions { display: flex; align-items: center; gap: 10px; }
.v-actions .btn.ghost { background: rgba(255,255,255,.1); color: #fff; }
.btn.like { background: rgba(224,122,95,.16); color: #ff9f86; }
.btn.like.pop { animation: likePop .4s ease; }
@keyframes likePop { 40% { transform: scale(1.18); } }
.v-count { margin-left: auto; color: #7d8681; font-size: 13px; font-weight: 600; }
.v-close { position: fixed; top: calc(14px + var(--safe-t)); right: 14px; width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,.12); color: #fff; font-size: 18px; z-index: 2; }
.v-nav { position: fixed; top: 50%; width: 48px; height: 64px; margin-top: -32px; border-radius: 14px; background: rgba(255,255,255,.08); color: #fff; font-size: 34px; line-height: 1; z-index: 2; }
.v-nav:hover { background: rgba(255,255,255,.16); }
.v-nav.prev { left: 12px; } .v-nav.next { right: 12px; }

@media (max-width: 820px) {
  .v-figure { grid-template-columns: 1fr; gap: 18px; }
  .v-img img { max-height: 58vh; border-width: 8px; }
  figcaption h2 { font-size: 22px; }
  .v-nav { top: auto; bottom: calc(16px + var(--safe-b)); width: 44px; height: 44px; margin: 0; font-size: 26px; }
  .viewer { place-items: start center; padding-bottom: 80px; }
}
@media (max-width: 560px) {
  .icon-btn { width: 46px; padding: 8px 0 6px; }
  .icon-btn span { display: none; }
  .hud-right { gap: 6px; }
  .title-chip { font-size: 14px; padding-left: 12px; }
  .overlay:not(#enter) { align-items: end; padding: 0; }
  .overlay:not(#enter) .card { border-radius: 24px 24px 0 0; padding-bottom: calc(26px + var(--safe-b)); max-height: 88vh; }
  .emotes button:nth-child(n+4) { display: none; }
}

/* 공지 · 신고 · 정보 */
.notice-bar { display: flex; width: 100%; gap: 10px; align-items: flex-start; justify-content: space-between; text-align: left; padding: 11px 14px; margin: 0 0 14px; border-radius: 14px; background: #fff7e6; border: 1px solid #f3dfb2; color: #6b4e12; font-size: 14px; font-weight: 600; line-height: 1.5; }
.notice-bar b { flex: none; opacity: .55; font-size: 13px; }
.gb-rp { margin-left: 8px; font-size: 12px; color: var(--muted); text-decoration: underline; padding: 0 2px; }
.about { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 8px; }
.about .btn { height: 40px; font-size: 14px; text-decoration: none; color: var(--ink); }
.about-ver { margin: 0 0 12px; font-size: 12px; color: var(--muted); user-select: none; -webkit-user-select: none; }

/* 작은 화면: 관장은 오른쪽 위 버튼이 4개 — 제목 칩이 줄어들어 버튼이 화면 밖으로 밀리지 않게 */
#hud { gap: 8px; }
.hud-left { min-width: 0; flex: 0 1 auto; grid-template-columns: minmax(0, 100%); }
.hud-right { flex: none; }
@media (max-width: 560px) {
  .icon-btn { width: 42px; }
  .hud-right { gap: 4px; }
  .title-chip { gap: 6px; }
}
