@import url('./theme.css');
@import url('./room-loading.css');
@import url('./policies.css');
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: #d9d6cf; }
html.sheet-open { overflow: hidden; overscroll-behavior: none; }
html.sheet-open body { position: fixed; top: var(--sheet-scroll-top); left: 0; right: 0; width: 100%; }
body { position: relative; isolation: isolate; max-width: 440px; min-height: 100svh; margin: 0 auto; color: var(--fg); background: radial-gradient(55% 35% at 100% 0%,var(--flash),transparent), radial-gradient(45% 30% at 0% 100%,var(--flash-low),transparent), var(--bg); font: 15px/1.6 -apple-system,BlinkMacSystemFont,"Apple SD Gothic Neo",system-ui,sans-serif; word-break: keep-all; overflow-wrap: anywhere; }
body::before { content: ''; position: absolute; z-index: -1; inset: 0; background: url('./grain.png'); mix-blend-mode: multiply; pointer-events: none; }
a { color: var(--fg); text-underline-offset: 3px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 16px 18px; }
.brand { font-weight: 800; letter-spacing: -.03em; text-decoration: none; font-size: 20px; }
.account { display: flex; gap: 10px; align-items: center; font-size: 12px; min-width: 0; flex-wrap: wrap; justify-content: flex-end; }
.account a { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
main { padding: 18px 18px 110px; }
h1 { font-size: 26px; line-height: 1.35; margin: 4px 0 10px; letter-spacing: -.03em; font-weight: 800; }
h2 { font-size: 21px; margin: 0 0 16px; line-height: 1.4; }
h3 { font-size: 15px; margin: 16px 0 6px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .error { color: var(--danger); margin: 6px 0; } .ok { color: var(--ok); }
p { margin: 8px 0; }
button,.button { font: inherit; font-size: 14px; min-height: 44px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--fg); text-decoration: none; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
button.primary,.button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
button.small { min-height: 40px; padding: 6px 10px; font-size: 12px; }
button.danger { color: var(--danger); }
button.link { border: 0; background: none; color: var(--fg); padding: 6px 2px; min-height: 40px; text-decoration: underline; text-underline-offset: 3px; font-size: inherit; }
button:disabled { opacity: .5; cursor: default; }
:focus { outline: none; }
input,select,textarea { font: inherit; font-size: 16px; width: 100%; padding: 12px; min-height: 46px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--fg); margin: 6px 0; }
input[type=checkbox] { width: auto; min-height: 0; flex-shrink: 0; margin: 6px 6px 0 0; accent-color: var(--fg); }
label { display: flex; align-items: flex-start; gap: 2px; margin: 10px 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 8px 0; }
.row select { width: auto; flex: 1; min-width: 100px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin: 12px 0; }
.room-head { min-height: 82px; }
.room-head #sub { margin: 0 0 6px; font-size: 12px; }
.room-identity { display: flex; align-items: center; gap: 12px; }
.identity-copy { flex: 1; min-width: 0; }
.avatar-portrait { display: block; width: 28px; height: 40px; flex-shrink: 0; image-rendering: pixelated; }
#avatar-status:empty { display: none; }
.avatar-form { display: flex; flex-direction: column; height: min(700px,calc(var(--pane-height,100svh) * .9 - 72px)); }
.avatar-form > h2 { flex-shrink: 0; }
.avatar-preview-frame { display: flex; align-items: center; gap: 18px; background: var(--bg); padding: 10px 0; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.avatar-preview-frame > div { min-width: 0; }
.avatar-preview { display: block; width: 112px; height: 160px; flex-shrink: 0; image-rendering: pixelated; background: var(--card); border-radius: 12px; }
.avatar-field { margin: 18px 0; padding: 0; border: 0; }
.avatar-fields { min-height: 0; flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 2px; }
.avatar-field legend { font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.avatar-options { display: flex; flex-wrap: wrap; gap: 8px; }
.avatar-option { gap: 6px; min-height: 44px; font-size: 12px; padding: 8px 10px; }
.avatar-option[aria-pressed=true] { border: 2px solid var(--fg); padding: 7px 9px; background: var(--card); }
.avatar-option:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.avatar-swatch { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgb(43 36 32 / .2); flex-shrink: 0; }
.avatar-save { background: var(--bg); padding: 10px 0; flex-shrink: 0; }
.avatar-save .primary { flex: 1; width: auto; }
@media(max-height:600px) { .avatar-preview { width:56px;height:80px; } .avatar-preview-frame { padding:6px 0; } .avatar-form > h2 { font-size:18px;margin-bottom:8px; } }
.stage { position: relative; max-width: 353px; margin: 26px auto 0; }
.stage canvas { display: block; margin: 0 auto; image-rendering: pixelated; touch-action: pan-y pinch-zoom; }
.bubbles { width: min(353px,100%); margin: 18px auto 4px; padding: 7px 2px 0; }
.bubbles:empty { display: none; }
.bubble { position: relative; width: 100%; min-height: 104px; padding: 14px 16px; border: 0; border-radius: 14px; background: var(--bubble); color: var(--bubble-ink); font-size: 12px; white-space: normal; }
.bubble span { overflow-wrap: anywhere; }
.bubble .bubble-content { display: block; }
.bubble::before { content: ''; position: absolute; top: -5px; left: 17px; border: 5px solid transparent; border-top: 0; border-bottom-color: var(--bubble); }
.bubble:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.bubble-title { display: block; font-size: 20px; line-height: 1.4; font-weight: 700; letter-spacing: -.03em; }
.bubble-author { display: block; margin: 0 0 6px; font-size: 11px; line-height: 1.4; opacity: .75; }
.answer-nav { display: flex; justify-content: center; align-items: center; gap: 18px; margin-top: 8px; }
.answer-nav button { width: 44px; height: 44px; padding: 0; border: 0; background: none; }
.answer-nav button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.answer-position { min-width: 34px; text-align: center; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.stamp { position: relative; display: block; text-align: right; min-height: 20px; padding-right: 16px; font: 700 15px/1.2 ui-monospace,"SF Mono",Menlo,monospace; letter-spacing: .12em; color: var(--stamp); text-shadow: 0 0 4px rgba(255,110,20,.15); }
.stage-caption,.answer-summary { text-align: center; margin: 10px 0 0; font-size: 12px; color: var(--muted); }
.answer-summary button { font-size: 12px; }
.question-picker { display: flex; gap: 6px; overflow-x: auto; margin-top: 14px; padding: 4px 2px 7px; }
.question-picker:empty { display: none; }
.question-picker button { flex-shrink: 0; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.chip { min-height: 38px; padding: 6px 10px; font-size: 12px; border-radius: 999px; }
.chip[aria-pressed=true] { background: var(--bubble); color: var(--bubble-ink); border-color: var(--bubble); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.ownerbar { justify-content: center; font-size: 12px; margin-top: 16px; }
.editbar { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; margin-top: 18px; }
.edit-selection { font-size: 13px; font-weight: 700; }
.edit-move { display: grid; grid-template-columns: repeat(4,minmax(44px,1fr)); gap: 8px; margin: 12px 0; }
.edit-move button { min-width: 44px; min-height: 44px; }
.editbar button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.surface-options { display: grid; gap: 10px; margin: 16px 0; }
.room-action { position: fixed; z-index: 2; bottom: 0; left: 50%; transform: translateX(-50%); width: min(440px,100%); padding: 14px 18px calc(18px + env(safe-area-inset-bottom)); background: linear-gradient(transparent,var(--bg) 32%); }
.room-action > * { width: 100%; min-height: 54px; border-radius: 14px; box-shadow: 0 7px 20px rgba(176,95,64,.16); }
body[data-handle] main { padding-bottom: 24px; }
body[data-handle] .room-action { position: static; transform: none; width: 100%; padding: 16px 0 calc(18px + env(safe-area-inset-bottom)); }
.answers { list-style: none; padding: 0; margin: 0; }
.answer { border-top: 1px solid var(--line); padding: 14px 0; }
.answer:first-child { border-top: 0; }
.reason { margin: 8px 0 0; white-space: pre-wrap; }
.pending { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 4px; }
.report summary { cursor: pointer; }
.foot { margin-top: 28px; text-align: center; }
dialog.sheet { border: 0; padding: 0; width: min(440px,100vw); max-width: 100vw; max-height: 90svh; margin: auto auto 0; border-radius: 22px 22px 0 0; color: var(--fg); background: var(--bg); overscroll-behavior: contain; }
dialog.sheet::backdrop { background: rgba(43,36,32,.4); }
.sheet-body { padding: 28px 18px calc(24px + env(safe-area-inset-bottom)); }
.sheet-body > h2:first-child,.sheet-body form > h2:first-child { padding-right: 40px; }
.sheet-body .primary { width: 100%; }
.sheet-close { position: absolute; right: 8px; top: 8px; width: 44px; height: 44px; padding: 0; border: 0; background: none; font-size: 22px; line-height: 1; }
.code { letter-spacing: .3em; font-size: 22px; text-align: center; }
.home h1 { margin-top: 18px; }
.home-room { display: block; width: 100%; max-width: 353px; height: auto; margin: 28px auto 0; image-rendering: pixelated; }
.home-note { text-align: center; }
@media(min-width:600px) { body { box-shadow: 0 0 40px rgba(43,36,32,.08); } }
/* 공통 드로워: 핸들만 끌고, 본문은 계속 스크롤한다. */
dialog.sheet { transition: transform 220ms cubic-bezier(.2,0,0,1); }
dialog.sheet.dragging { transition: none; }
dialog.sheet::backdrop { background: rgb(43 36 32 / var(--sheet-dim,.4)); }
.sheet-handle { position: sticky; top: 0; z-index: 2; display: flex; width: 100%; height: 28px; min-height: 28px; padding: 9px; border: 0; border-radius: 22px 22px 0 0; background: var(--bg); touch-action: none; cursor: grab; }
.sheet-handle span { display: block; width: 38px; height: 4px; border-radius: 99px; background: var(--muted); opacity: .65; }
.dragging .sheet-handle { cursor: grabbing; }
.sheet-close { top: 30px; z-index: 1; }
.sheet-body { padding-top: 14px; }
.row .birth-year,.row .birth-month { flex: 1; width: 0; min-width: 100px; }
@media(prefers-reduced-motion:reduce) { dialog.sheet { transition: none; } }
/* 질문함은 방 안의 여러 질문으로 들어가는 입구다. */
.question-picker { overflow: visible; align-items: center; flex-wrap: wrap; font-size: 12px; }
.question-box-button { background: transparent; border-color: var(--muted); border-radius: 999px; min-height: 38px; padding: 5px 12px; font-size: 12px; font-weight: 700; }
.question-state { display: inline-block; font-size: 11px; color: var(--muted); font-weight: 400; }
.question-row { border-top: 1px solid var(--line); padding: 10px 0; display: flex; gap: 8px; align-items: center; }
.question-open { flex: 1; min-width: 0; padding: 8px 0; border: 0; background: none; display: grid; gap: 4px; text-align: left; justify-content: start; }
.question-open strong { font-size: 16px; line-height: 1.45; }
.question-open span { white-space: normal; }
.bubble { display: block; text-align: left; }
.bubble-label { display: block; }
.bubble-meta { display: block; margin-top: 9px; font-size: 10px; line-height: 1.3; opacity: .75; }
.discussion-controls { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin: 4px 0 0; }
.heart-button { min-width: 0; min-height: 44px; padding: 0; gap: 5px; border: 0; border-radius: 0; background: none; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.heart-button[aria-pressed=true] { color: var(--fg); font-weight: 700; }
.heart-mark { font: 14px/1 Georgia,serif; }
.reply-count { border: 0; background: none; min-height: 44px; padding: 0; color: var(--muted); font-size: 12px; text-decoration: none; }
.reply-list { list-style: none; padding: 0; margin: 8px 0 16px; }
.reply-item,.pending-reply { padding: 12px 0; border-top: 1px solid var(--line); }
.reply-text { white-space: pre-wrap; margin: 6px 0; }
.reply-actions { font-size: 12px; margin-bottom: 0; }
.reply-state { font-size: 11px; color: var(--muted); }
.private-replies { border: 1px dashed var(--muted); border-radius: 12px; padding: 0 12px; margin: 14px 0; }
.private-replies .reply-list { margin: 0; }
.private-replies .reply-item:first-child { border: 0; }
.reply-form { border-top: 1px solid var(--line); padding-top: 14px; }
.compose-status { display: inline-block; padding: 5px 10px; border-radius: 10px; background: var(--bubble); color: var(--bubble-ink); font-size: 11px; }
.incoming-preview { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; font-size: 13px; color: var(--muted); }
.incoming-response { border-top: 1px solid var(--line); margin-top: 16px; padding: 8px 0; }
.visit-summary { margin-top: 8px; text-align: center; font-size: 12px; color: var(--muted); }
.visit-summary button.link { margin-left: 8px; min-height: 36px; font-size: 12px; }
.visit-notice { margin: 0; font-size: 11px; }
.visit-stats { display: flex; gap: 36px; margin: 20px 0 12px; }
.visit-stats strong,.visit-stats span { display: block; }
.visit-stats strong { font-size: 28px; line-height: 1.3; }
.visit-stats span { font-size: 12px; color: var(--muted); }
.visitors { list-style: none; padding: 0; margin: 16px 0 0; }
.visitor { border-top: 1px solid var(--line); padding: 12px 0; }
.visit-empty { padding: 20px 0; }
.story-preview { display: block; width: auto; max-width: 100%; height: clamp(140px, calc(var(--pane-height, 100svh) * .42), 480px); margin: 18px auto; border-radius: 12px; }
.story-copy { font-size: 12px; word-break: break-all; }
.furniture-filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.furniture-filters .chip { font-size: 12px; padding: 7px 10px; }
.furniture-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(108px,1fr)); gap: 8px; }
.furniture-option { min-width: 0; padding: 8px 3px; flex-direction: column; gap: 6px; font-size: 11px; border-radius: 12px; }
.furniture-icon { display: block; width: 96px; height: 96px; flex-shrink: 0; background-image: url('./slices-48/thumbnails.png'); background-repeat: no-repeat; image-rendering: pixelated; }
.sign-preview { display: block; width: 100%; max-width: 336px; height: auto; image-rendering: pixelated; margin: 16px auto; }
/* 브라우저 도구막대로 세로가 짧아져도 방을 가리지 않고 아래로 이어 읽는다. */
@media (max-height: 800px) {
  body[data-handle] .top { padding-top: 10px; padding-bottom: 6px; }
  body[data-handle] main { padding-top: 10px; padding-bottom: 12px; }
  .room-head { min-height: 0; }
  .room-head h1 { font-size: 23px; }
  .question-picker { margin-top: 8px; }
  .stage { max-width: min(353px, max(220px, calc((100svh - 370px) * 1.2))); margin-top: 14px; }
  body[data-handle] .foot { margin-top: 12px; }
  body[data-handle] .room-action { position: static; transform: none; width: 100%; margin: 0 auto; padding-top: 8px; }
}
/* 두 화면으로 펼친 기기는 첫 패널 안에 본문·버튼·드로워를 함께 둔다. */
@media (horizontal-viewport-segments: 2), (vertical-viewport-segments: 2) {
  :root {
    --pane-width: env(viewport-segment-width 0 0);
    --pane-height: env(viewport-segment-height 0 0);
    --pane-left: env(viewport-segment-left 0 0);
    --pane-margin: max(0px, calc(var(--pane-left) + (var(--pane-width) - 440px) / 2));
  }
  body,html.sheet-open body { width: min(440px, var(--pane-width)); margin-left: var(--pane-margin); margin-right: 0; }
  .room-action { width: min(440px, var(--pane-width)); left: calc(var(--pane-left) + var(--pane-width) / 2); }
  dialog.sheet { width: min(440px, var(--pane-width)); max-height: calc(var(--pane-height) * .9); margin-left: var(--pane-margin); margin-right: 0; margin-bottom: calc(100svh - env(viewport-segment-bottom 0 0)); }
}
@media (vertical-viewport-segments: 2) {
  html { overflow: hidden; }
  body { height: var(--pane-height); min-height: 0; overflow-y: auto; }
  html.sheet-open body { overflow: hidden; }
  body[data-handle] main { padding-bottom: 12px; }
  .stage { max-width: min(353px, max(220px, calc((var(--pane-height) - 370px) * 1.2))); }
  body[data-handle] .room-action { position: static; transform: none; width: 100%; margin: 0 auto; padding-top: 8px; }
}
@media (max-height: 800px), (max-width: 340px), (vertical-viewport-segments: 2) {
  .bubble { min-height: 96px; padding: 12px 14px; font-size: 11px; }
  .bubble-meta { font-size: 9px; }
}

/* Keep account confirmation readable on narrow screens. */
label.withdrawal-handle { display: block; }

/* Internal exception review stays within the existing operator panel. */
.exception-review{margin-top:24px;padding-top:18px;border-top:1px solid var(--line,#bda6a0)}.exception-records{min-width:0;border:1px solid var(--line,#bda6a0);padding:12px;border-radius:12px}.exception-review .exception-ref{display:flex;align-items:flex-start;gap:8px;margin:10px 0;min-width:0}.exception-review .exception-ref input{width:20px;height:20px;flex:0 0 20px;margin-top:4px}.exception-ref span{min-width:0}.exception-ref code{display:block;font-size:12px;overflow-wrap:anywhere}.exception-review input[type=datetime-local]{min-width:0;width:100%;box-sizing:border-box}
.record-assessment{margin:10px 0;padding:12px;border:1px solid var(--line,#bda6a0);border-radius:12px;min-width:0}.record-assessment>summary{cursor:pointer;min-height:36px;font-weight:700}.record-assessment>code{display:block;overflow-wrap:anywhere;font-size:12px;margin-bottom:12px}.record-assessment textarea{min-height:80px}.record-assessment>label,.record-assessment>div{margin:12px 0}.record-assessment [hidden]{display:none}
.record-assessment label{overflow-wrap:anywhere}
.retention-lines,[data-withdrawal-guidance]>p:nth-of-type(1){white-space:pre-line}
.record-bulk{margin:10px 0;padding:12px;border:1px dashed var(--line,#bda6a0);border-radius:12px;min-width:0;display:grid;gap:8px}.record-bulk textarea{min-height:56px}
