/* 온기정원 — 저녁빛 성당. 자줏빛 밤 + 황동 + 상아. 글꼴은 명조(제목) + 시스템 고딕(본문). */
:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --ink: #fff7e9;
  --ink-soft: #f0e7da;
  --brass: #efd8b1;
  --glass: linear-gradient(135deg, #302933e6, #393039de);
  --glass-line: #efd8b15c;
  --paper: #f7f2e9;
  --paper-ink: #363334;
  --paper-soft: #6b625b;
  --accent: #514d47;
  --serif: Georgia, "Noto Serif KR", "Nanum Myeongjo", "Batang", serif;
  --sans: system-ui, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  --gap: 12px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; touch-action: manipulation; }
body { margin: 0; overflow: hidden; background: #373e50; color: var(--ink); font: 15px/1.5 var(--sans); }
body.bigtext { font-size: 18px; }
#world, #world canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
#world { background: #554a4d url(art/hall-0.jpg) center/cover no-repeat; }
body::before { content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 1; background: linear-gradient(180deg, #211b2a8c 0%, transparent 21%, transparent 64%, #211a2d9c 100%), linear-gradient(90deg, #23192733, transparent 35%); }
header, nav, aside, footer, #walk, #caption, output { position: fixed; z-index: 2; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, label:focus-within { outline: 3px solid #ffc985; outline-offset: 2px; }
[hidden] { display: none !important; }

/* 상단: 상호 + 나의 봉안함 */
header { top: calc(var(--safe-top) + 20px); left: calc(var(--safe-left) + 4%); right: calc(var(--safe-right) + 4%); display: flex; justify-content: space-between; align-items: center; pointer-events: none; }
header button { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand b { font: 500 23px var(--serif); letter-spacing: 3px; }
.brand small { display: block; font: 9px Georgia, serif; letter-spacing: 2.2px; margin-top: 5px; opacity: .85; }
.seal { font-size: 30px; border: 1px solid #d8c59b; border-radius: 50% 50% 7px 7px; padding: 0 7px; color: #f9e7c5; }
.pill, nav, aside button, footer, #walk { border: 1px solid var(--glass-line); background: var(--glass); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); box-shadow: 0 8px 32px #28172540; }
.pill { border-radius: 24px; padding: 11px 18px; min-height: 44px; max-width: 52vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill b { font-weight: 500; }

/* 공간 이동 */
nav { top: calc(var(--safe-top) + 24px); left: 50%; transform: translateX(-50%); border-radius: 25px; display: flex; padding: 4px; white-space: nowrap; }
nav button { border-radius: 20px; padding: 9px 15px; min-height: 40px; font-size: 13px; color: #ece4d6; transition: background .25s, color .25s; }
nav [aria-pressed="true"] { background: #f3e5c9; color: #493a36; }

/* 장소 제목 */
#caption { left: calc(var(--safe-left) + 4%); bottom: 24%; pointer-events: none; text-shadow: 0 2px 12px #302b24; max-width: 70vw; }
#caption small { letter-spacing: 3px; font: 10px Georgia, serif; color: #ffdfaa; }
h1 { font: 400 clamp(33px, 5vw, 65px) var(--serif); letter-spacing: -1px; margin: 10px 0; }
#caption p { margin: 0; color: var(--ink-soft); }

/* 오른쪽 둥근 단추 */
aside { right: calc(var(--safe-right) + 3%); bottom: calc(var(--safe-bottom) + 5%); display: flex; gap: 8px; }
aside button { border-radius: 50%; width: 44px; height: 44px; font-size: 17px; transition: transform .2s, background .2s; }
aside button[aria-pressed="true"] { background: #f3e5c9; color: #493a36; }
aside button:active { transform: scale(.94); }

/* 추모 동작 */
footer { bottom: calc(var(--safe-bottom) + 4%); left: 50%; transform: translateX(-50%); border-radius: 19px; display: flex; padding: 5px 8px; }
footer button { padding: 8px 18px; min-height: 56px; white-space: nowrap; font-size: 13px; transition: transform .15s; }
footer button:active { transform: translateY(1px) scale(.97); }
footer button + button { border-left: 1px solid #ffffff24; }
em { font: 22px Georgia, serif; display: block; margin-bottom: 2px; color: #f2d4a0; font-style: normal; }

/* 이동 단추 */
#walk { bottom: calc(var(--safe-bottom) + 5%); left: calc(var(--safe-left) + 4%); width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center; touch-action: none; }
#walk i { width: 32px; height: 32px; border: 1px solid #e6d9c69c; background: #f4e9d644; border-radius: 50%; transition: transform .08s; }
.panorama #walk { display: none; }

/* 알림 */
output { left: 50%; bottom: calc(var(--safe-bottom) + 135px); transform: translateX(-50%); border-radius: 18px; background: #23272df0; text-align: center; padding: 10px 18px; max-width: 88vw; width: max-content; box-shadow: 0 10px 30px #0004; animation: rise .25s ease-out; }
output:empty { display: none; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 6px); } }

/* 대화상자 */
dialog { width: min(440px, 92vw); border: 1px solid #c9bba3; background: var(--paper); color: var(--paper-ink); border-radius: 20px; padding: 0; max-height: min(86dvh, 820px); box-shadow: 0 30px 100px #0005; }
dialog[open] { animation: open .22s ease-out; }
@keyframes open { from { opacity: 0; transform: translateY(10px) scale(.98); } }
dialog::backdrop { background: #141a2580; backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
#panel { padding: 26px 24px 24px; max-height: inherit; overflow: auto; overscroll-behavior: contain; }
h2 { font: 400 26px var(--serif); margin: 2px 36px 14px 0; line-height: 1.25; }
h3 { font: 600 13px var(--sans); letter-spacing: .5px; color: var(--paper-soft); margin: 22px 0 8px; text-transform: none; }
dialog p, dialog li { line-height: 1.7; font-size: 14px; }
.bigtext dialog p, .bigtext dialog li, .bigtext label { font-size: 17px; }
.lead { font-size: 15px; margin: 0 0 12px; }
.note { color: var(--paper-soft); font-size: 13px !important; margin: 10px 0; }
.close { position: sticky; top: 0; float: right; font-size: 26px; width: 44px; height: 44px; margin: -10px -8px 0 0; border-radius: 50%; z-index: 1; }
label { display: block; font-size: 13px; margin-top: 16px; }
input, textarea, select { font: inherit; color: #37332e; width: 100%; margin-top: 6px; padding: 11px; border-radius: 10px; background: #fffdf9; border: 1px solid #cfc5b6; min-height: 44px; }
input[type="file"] { padding: 9px; }
textarea { height: 120px; resize: vertical; }
.count { text-align: right; margin: 4px 0 0 !important; font-size: 12px !important; color: var(--paper-soft); }
.save, .ghost, .mini, .btnlink { display: inline-flex; align-items: center; justify-content: center; border-radius: 12px; min-height: 48px; padding: 12px 18px; font-weight: 600; text-decoration: none; }
.save { margin-top: 18px; background: var(--accent); color: #fff; width: 100%; }
.save:disabled { opacity: .5; }
.ghost { margin-top: 10px; width: 100%; border: 1px solid #bdb1a0; color: var(--paper-ink); background: #fffaf2; }
.mini { min-height: 40px; padding: 8px 14px; font-size: 13px; border: 1px solid #bdb1a0; background: #fffaf2; color: var(--paper-ink); }
.link { color: #6d5638; text-decoration: underline; padding: 10px 0; margin-top: 6px; }
.actions { display: grid; gap: 0; }
.actions .save + .ghost { margin-top: 10px; }
.filebtn { position: relative; overflow: hidden; cursor: pointer; }
.filebtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; font-size: 14px; }
.row .inline { display: flex; gap: 6px; }
.row .inline input { width: 7.5em; margin: 0; }
.prior { padding: 10px 12px; margin: 10px 0 0; border-left: 2px solid #b8955e; background: #fffaf2; border-radius: 0 10px 10px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.photo { width: 84px; height: 84px; object-fit: cover; border-radius: 14px; border: 2px solid #d2ad6c; }

/* 봉안함 카드 */
.pets { display: grid; gap: 8px; }
.pet { display: flex; gap: 12px; align-items: center; text-align: left; padding: 10px; border-radius: 14px; border: 1px solid #ddd2c2; background: #fffcf6; min-height: 72px; transition: border-color .2s, box-shadow .2s; }
.pet.on { border-color: #b8955e; box-shadow: 0 0 0 2px #e8cf9f inset; }
.pet img, .pet .ph { width: 56px; height: 56px; border-radius: 12px; object-fit: cover; flex: none; }
.pet .ph { display: grid; place-items: center; background: #efe5d6; color: #a5865a; font-size: 22px; }
.pet b { display: block; font: 500 17px var(--serif); overflow-wrap: anywhere; }
.pet small { display: block; color: var(--paper-soft); font-size: 12px; }

/* 칸 고르기 */
.seg { display: flex; gap: 6px; margin: 4px 0 6px; }
.seg button { flex: 1; min-height: 44px; border-radius: 12px; border: 1px solid #cfc5b6; background: #fffaf2; }
.seg [aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }
.grid { display: grid; grid-template-columns: repeat(var(--cols), 44px); gap: 4px; overflow-x: auto; padding: 4px 2px 10px; scroll-snap-type: x proximity; }
.cell { height: 44px; border-radius: 8px; background: #4a3f45; color: #f6e6c6; border: 1px solid #6c5c58; font: 15px var(--serif); scroll-snap-align: center; }
.cell small { font: 11px var(--sans); opacity: .55; }
.cell.taken { background: #cbbfae; color: #3d332d; border-color: #b4a691; cursor: not-allowed; }
.cell.on { background: #e9c98b; color: #3d2f24; border-color: #b8955e; box-shadow: 0 0 0 2px #fff inset; }

/* 설정 */
.switch { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 6px 0; margin-top: 8px; }
.switch small { display: block; color: var(--paper-soft); font-size: 12px; }
.switch input { width: 46px; height: 26px; min-height: 0; margin: 0; flex: none; accent-color: var(--accent); }
.about { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.about div { background: #fffaf2; border: 1px solid #e3d8c8; border-radius: 12px; padding: 10px 12px; }
.about span { display: block; font-size: 12px; color: var(--paper-soft); }
.about b { font-weight: 600; overflow-wrap: anywhere; }
.links { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 14px; font-size: 13px; }
.links a { color: #6d5638; padding: 8px 0; }
.plan, .benefits { padding-left: 18px; }
.plans { display: grid; gap: 8px; }
.plans .save { margin-top: 6px; }
.plans .ghost { margin-top: 0; }

/* 관리자 */
.atabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; margin-right: -4px; }
.atabs button { white-space: nowrap; border: 1px solid #cfc5b6; border-radius: 18px; padding: 8px 12px; min-height: 40px; font-size: 13px; background: #fffaf2; }
.atabs [aria-pressed="true"] { background: var(--accent); color: #fff; }
.checks { list-style: none; padding: 0; }
.checks .ok { color: #2f6b3f; }
.checks .no { color: #a0352c; }
.errs { padding-left: 18px; font-size: 13px; overflow-wrap: anywhere; }
.warn { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: #fbe9d0; color: #7a4a14; font-size: 14px; }

/* 또렷한 대비 */
.contrast { --glass: #17131bf2; --glass-line: #fff3d6; --paper-soft: #3d3631; }
.contrast nav button, .contrast footer button { color: #fff; }
.contrast #caption { text-shadow: 0 0 3px #000, 0 2px 12px #000; }
.contrast .cell { border-width: 2px; }

/* 휴대폰 세로 */
@media (max-width: 780px) {
  header { top: calc(var(--safe-top) + 14px); }
  .brand b { font-size: 20px; }
  .seal { font-size: 26px; }
  nav { top: calc(var(--safe-top) + 72px); }
  nav button { padding: 9px 12px; }
  /* 세로 화면: 제목을 위로 올려 가운데(사진·명패)를 비운다 */
  #caption { top: calc(var(--safe-top) + 128px); bottom: auto; max-width: 62vw; }
  #caption small { display: none; }
  h1 { font-size: 26px; margin: 0 0 2px; }
  #caption p { font-size: 13px; }
  footer { left: calc(var(--safe-left) + 12px); right: calc(var(--safe-right) + 12px); transform: none; bottom: calc(var(--safe-bottom) + 12px); padding: 4px; }
  footer button { flex: 1; padding: 6px 4px; }
  aside { bottom: calc(var(--safe-bottom) + 96px); right: calc(var(--safe-right) + 12px); }
  #walk { bottom: calc(var(--safe-bottom) + 88px); left: calc(var(--safe-left) + 12px); width: 64px; height: 64px; }
  output { bottom: calc(var(--safe-bottom) + 166px); }
  .pill { padding: 10px 14px; font-size: 13px; }
}
@media (max-width: 380px) {
  .brand small { display: none; }
  nav button { font-size: 12px; padding: 9px 9px; }
}
/* 가로 화면(낮은 높이) */
@media (max-height: 520px) and (min-width: 600px) {
  header { top: calc(var(--safe-top) + 10px); }
  nav { top: calc(var(--safe-top) + 10px); }
  #caption { bottom: 30%; }
  #caption p { display: none; }
  h1 { font-size: 30px; margin: 4px 0; }
  footer { bottom: calc(var(--safe-bottom) + 10px); }
  footer button { min-height: 48px; }
  em { font-size: 18px; }
  aside, #walk { bottom: calc(var(--safe-bottom) + 12px); }
  output { bottom: calc(var(--safe-bottom) + 80px); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
.noscript { position: fixed; inset: auto 0 40% 0; z-index: 3; text-align: center; }
