/* 채팅 화면을 풀이와 같은 결로 맞춘다.
   report.css 의 토큰(--report-ink, --report-surface, --report-radius …)을 그대로 쓰고,
   style.css 의 크림·세리프 테마는 이 화면에서만 덮는다.
   landing.css 가 첫 화면에 하는 일과 같은 방식이다.

   구조도 바꾼다. 카드 안에 갇힌 스크롤 상자였는데,
   풀이처럼 글이 페이지에 그대로 흐르고 입력창만 아래에 붙는다. */

html:has(#chat-screen.active), body:has(#chat-screen.active) { background: transparent; }
.shell:has(#chat-screen.active) { width: min(calc(100% - (var(--app-gutter) * 2)), calc(var(--app-max-width) - (var(--app-gutter) * 2))); padding: 28px 0 0; }
#chat-screen { color: var(--report-ink); --muted: var(--report-muted); --line: var(--report-line); }

/* 머리 */
#chat-screen .screen-heading { margin-bottom: 24px; }
#chat-screen .section-kicker { color: #64758d; font-size: 11px; letter-spacing: .1em; }
#chat-screen h2 { color: var(--report-ink); font: 700 30px/1.35 var(--sans); letter-spacing: -.04em; }
#chat-screen .text-button { padding: 7px 0; color: #64758d; font: 500 13px/1.4 var(--sans); text-decoration: none; }
#chat-screen .text-button:hover { color: #455a76; text-decoration: underline; text-underline-offset: 3px; }

/* 인물 고르기 — 세 사람을 나란히. 고른 쪽만 색이 찬다. */
.persona-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 28px; }
#chat-screen .persona-tab {
  display: grid; justify-items: center; gap: 7px; padding: 16px 6px 14px;
  border: 1px solid var(--report-line); border-radius: var(--report-radius);
  background: #fff; color: var(--report-muted); text-align: center; cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
#chat-screen .persona-tab:hover { border-color: #c3cedd; }
#chat-screen .persona-tab.active { border-color: #455a76; background: #f2f5f9; }
#chat-screen .persona-tab strong { color: var(--report-ink); font: 600 15px/1.4 var(--sans); letter-spacing: -.03em; }
#chat-screen .persona-tab.active strong { color: #455a76; font-weight: 700; }
#chat-screen .persona-tab small { margin-top: 0; color: var(--report-meta); font: 400 11px/1.4 var(--sans); }
#chat-screen .persona-avatar { width: 52px; height: 52px; background: var(--report-surface); }
#chat-screen .persona-tab.active .persona-avatar { box-shadow: 0 0 0 2px #fff, 0 0 0 3px rgba(69,90,118,.35); }

/* 카드를 걷어 낸다. 풀이처럼 흰 바탕에 글이 그대로 흐른다. */
#chat-screen .chat-card { min-height: 0; padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; }

/* 지금 누구와 이야기하는지 — 위에 붙어 따라온다 */
#chat-screen .chat-stage {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 12px;
  margin: 0 0 24px; padding: 12px 0;
  border-bottom: 1px solid var(--report-line); background: rgba(255,255,255,.92);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
}
#chat-screen .chat-stage-avatar { width: 44px; height: 44px; flex-basis: 44px; background: var(--report-surface); box-shadow: none; }
#chat-screen .chat-stage-copy { gap: 1px; }
#chat-screen .chat-stage-copy strong { color: var(--report-ink); font: 600 16px/1.4 var(--sans); letter-spacing: -.03em; }
#chat-screen .chat-stage-copy span { color: var(--report-meta); font: 400 12px/1.4 var(--sans); }

#chat-screen .persona-tab { min-width: 0; }
#chat-screen .persona-sub { display: flex; align-items: center; gap: 6px; white-space: nowrap; min-width: 0; }
#chat-screen .persona-sub i { display: block; flex: 0 1 44px; width: 44px; min-width: 20px; height: 4px; border-radius: 2px; background: #e6e9ef; overflow: hidden; }
#chat-screen .persona-sub b { display: block; height: 100%; border-radius: 2px; background: #b9985a; transition: width .5s ease; }
#chat-screen .chat-bond-up { margin-top: 6px; color: #8a6420; font-style: normal; font-weight: 600; }

/* 말 — 풀이 본문과 같은 회색 카드(#f5f6f8), 같은 본문 서체 */
/* 말풍선 목록은 이 한 규칙이 전부 정한다. id 선택자라 아래 규칙들이 못 덮는다. */
#chat-screen .chat-messages { display: grid; gap: 16px; min-height: 0; max-height: none;
  overflow-y: auto; overscroll-behavior: contain; scroll-behavior: smooth; padding: 14px 2px 10px; }
/* 같은 사람이 연달아 말하면 한 덩어리로 붙인다. */
#chat-screen .chat-messages .message.grouped { margin-top: -13px; }
#chat-screen .message { gap: 10px; max-width: 92%; }
#chat-screen .avatar { width: 34px; height: 34px; flex-basis: 34px; background: var(--report-surface); color: var(--report-muted); }
#chat-screen .message.user .avatar { background: #eef1f6; color: #455a76; }
#chat-screen .bubble {
  padding: 15px 17px; border-radius: 4px 16px 16px 16px;
  color: var(--report-ink); background: var(--report-surface);
  font: 400 15px/1.85 var(--dialogue-font); letter-spacing: -.025em;
}
#chat-screen .message.user .bubble { border-radius: 16px 4px 16px 16px; background: #455a76; color: #fff; }
#chat-screen .empty-chat {
  justify-self: stretch; padding: 44px 20px; border-radius: var(--report-radius);
  background: var(--report-surface); color: var(--report-muted);
  font: 400 15px/1.8 var(--dialogue-font); letter-spacing: -.025em; text-align: center;
}

#chat-screen .typing { gap: 4px; height: 30px; padding-left: 44px; color: var(--report-meta); }
#chat-screen .typing span { width: 6px; height: 6px; background: #8fa2bb; }
#chat-screen .typing { height: auto; min-height: 30px; }
#chat-screen .typing em { margin-left: 8px; font: 400 12px/1.45 var(--sans); }
#chat-screen .chat-retry {
  align-self: flex-start; margin-top: 6px; padding: 7px 14px; border: 1px solid #c9a98f; border-radius: 999px;
  background: #fffaf3; color: #6b4a36; font: 500 13px/1 var(--sans); cursor: pointer;
}
#chat-screen .chat-retry:hover { background: #f8efe3; }

/* 입력창 — 아래에 붙어 따라온다 */
#chat-screen .chat-form {
  position: sticky; bottom: 0; z-index: 2;
  gap: 10px; padding: 10px 0 env(safe-area-inset-bottom, 0);
  border-top: 1px solid var(--report-line); background: rgba(255,255,255,.94);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
}
#chat-screen .chat-form textarea {
  min-height: 48px; max-height: 120px; padding: 13px 18px;
  border: 1px solid var(--report-line); border-radius: 24px; background: #fff;
  color: var(--report-ink); font: 400 15px/1.5 var(--sans); letter-spacing: -.02em;
}
#chat-screen .chat-form textarea::placeholder { color: #aab2bd; }
#chat-screen .chat-form textarea:focus { border-color: #7c93b3; outline: 2px solid rgba(69,90,118,.14); outline-offset: 1px; }
#chat-screen .chat-form button { width: 48px; height: 48px; flex-basis: 48px; background: #455a76; color: #fff; font-size: 20px; }
#chat-screen .chat-form button:hover:not(:disabled) { background: #3a4c65; }
#chat-screen .chat-form button:disabled { background: #9aa8bb; opacity: 1; }

#chat-screen ::selection { background: rgba(69,90,118,.18); color: var(--report-ink); }

@media (max-width: 400px) {
  #chat-screen h2 { font-size: 26px; }
  #chat-screen .persona-tab { padding: 13px 4px 11px; }
  #chat-screen .persona-avatar { width: 44px; height: 44px; }
  #chat-screen .message { max-width: 96%; }
}




/* ── 묘사 + 대화. 앞으로 모든 대사가 이 형식이다 ── */
.chat-act { display: block; margin-bottom: 6px; font-style: italic; font-size: 12.5px; line-height: 1.6; color: #8b929d; }
.message.user .chat-act { color: #d7cfc0; }
.chat-say { margin: 0 0 7px; line-height: 1.75; }
.chat-say:last-child { margin-bottom: 0; }

/* ── 카톡처럼 — 왼쪽 주월, 오른쪽 나, 아바타 옆에 이름 ── */
.message-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.message-name { font-size: 11.5px; color: #8b929d; padding-left: 2px; }
.message.grouped .message-body { padding-left: 0; }
/* 채팅은 화면에 고정하고 말풍선 목록만 스크롤한다 */
body.is-chat { overflow: hidden; height: 100svh; padding-bottom: 0 !important; }
/* 사이트 헤더가 fixed 라 100svh 로 잡으면 그만큼 아래가 잘린다. 헤더 아래를 통째로 채운다. */
body.is-chat #chat-screen.active {
  position: fixed; top: var(--site-header-height, 64px); bottom: 0; left: 50%; z-index: 20;
  width: min(100%, var(--app-max-width)); margin: 0; transform: translateX(-50%); animation: none;
  display: flex; flex-direction: column; min-height: 0; margin: 0;
  padding: 0 max(14px, env(safe-area-inset-left)) 0 max(14px, env(safe-area-inset-right));
  background: var(--paper, #fffdf8);
}
body.is-chat .chat-card { flex: 1; display: flex; flex-direction: column; min-height: 0; margin: 0; padding: 0; border: 0; background: none; }
#chat-screen .chat-messages { flex: 1; }

/* ── 답장 자리 — 선택지가 입력창 자리에 서고, 입력창은 모양만 보인다 ── */
.chat-composer { flex-shrink: 0; background: var(--paper, #fffdf8); padding-bottom: env(safe-area-inset-bottom); }
/* 입력창이 있던 자리를 그대로 차지한다. 보내기 버튼은 옆에 그대로 남는다. */
.prologue-choices { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px;
  max-height: 40svh; overflow-y: auto; }
.prologue-choices[hidden] { display: none; }
#chat-screen.is-prologue .chat-form textarea { display: none; }
/* 폼 안의 버튼은 style.css 가 43px 원형으로 잡는다(보내기 버튼). 칩은 그 규칙을 되돌린다. */
#chat-screen .chat-form .prologue-choice {
  width: auto; height: auto; flex: 0 0 auto;
  padding: 11px 17px; border: 1px solid #cfc6b4; border-radius: 999px; background: #fffdf7;
  font-size: 14.5px; line-height: 1.3; color: #4a4335; white-space: nowrap; cursor: pointer; }
.prologue-choice:active { transform: scale(.97); }
#chat-screen .chat-form .prologue-choice.is-quiet { border-color: #e6e6ea; background: #fff; color: #9aa0aa; }
#chat-screen .chat-form .prologue-choice.is-go { border-color: #2f3947; background: #2f3947; color: #f6f2e8; font-weight: 600; }
#chat-screen .chat-form .prologue-choice:focus-visible { outline: 2px solid #b9985a; outline-offset: 3px; }

/* 프롤로그 — 탭·달력·풀이 버튼을 감추고, 입력창은 잠긴 모양으로만 보여 준다 */
#chat-screen.is-prologue .chat-topbar { display: none; }
/* 보내기 버튼만 잠근다. 같은 폼 안의 선택지 칩까지 막으면 아무것도 못 누른다. */
#chat-screen.is-prologue .chat-form > button[type="submit"] { opacity: .45; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .prologue-choice:active { transform: none; } }

/* 장면 지문 — 말풍선 밖에서 무대를 세우는 글 */
.chat-narration { margin: 4px 6px 6px; padding: 0 0 0 11px; border-left: 2px solid #e0d8c6;
  font-size: 13px; line-height: 1.85; color: #8b8375; text-align: left; letter-spacing: -.01em; }

/* 지문과 말풍선은 하나씩 떠오르듯 들어온다. 하드 컷을 줄이는 가장 싼 방법이다. */
#chat-screen .chat-messages > * { animation: chat-rise .32s ease-out both; }
@keyframes chat-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
#chat-screen .prologue-choices { animation: chat-rise .28s ease-out both; }
@media (prefers-reduced-motion: reduce) {
  #chat-screen .chat-messages > *, #chat-screen .prologue-choices { animation: none; }
}

/* 폼과 상담실 사이의 한 컷 */
.transit-overlay { position: fixed; top: 0; bottom: 0; left: 50%; width: min(100%, var(--app-max-width)); transform: translateX(-50%); z-index: 90; display: grid; place-items: center;
  background: #fffdf8; animation: calc-fade .35s ease both; }
.transit-overlay[hidden] { display: none; }
.transit-card { margin: 0; display: grid; justify-items: center; gap: 20px; padding: 0 24px; text-align: center; }
.transit-card img { width: min(52vw, 200px); height: auto; border-radius: 50%; object-fit: cover;
  box-shadow: 0 14px 36px rgba(74,55,35,.14); animation: transit-rise .55s ease-out both; }
.transit-card figcaption { display: grid; gap: 7px; animation: transit-rise .55s .12s ease-out both; }
.transit-card strong { font: 600 20px/1.4 var(--serif, serif); color: #3f4854; }
.transit-card span { font-size: 14.5px; color: #8b8375; }
@keyframes transit-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .transit-overlay, .transit-card img, .transit-card figcaption { animation: none; }
}

/* chatux reference: one conversation and narration separated from speech.
   Colors deliberately stay on Wolhwadam's original paper theme. */
.shell:has(#chat-screen.active) { width: min(100%, var(--app-max-width)); padding-top: 0; }
#chat-screen .chat-topbar {
  min-height: 70px; margin: 0 -14px; padding: 10px 16px;
  display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 8px;
  border-bottom: 1px solid var(--report-line); background: rgba(255,253,248,.96);
}
#chat-screen .chat-back { padding: 0; border: 0; background: transparent; color: var(--report-ink); font: 300 42px/1 var(--sans); cursor: pointer; }
.persona-tabs { display: block; margin: 0; }
#chat-screen .persona-tab, #chat-screen .persona-tab.active {
  display: grid; grid-template-columns: 44px 1fr; grid-template-rows: auto auto; column-gap: 10px;
  width: 100%; padding: 0; border: 0; background: transparent; text-align: left; cursor: default;
}
#chat-screen .persona-tab:hover { border-color: transparent; }
#chat-screen .persona-avatar { grid-row: 1 / 3; width: 44px; height: 44px; }
#chat-screen .persona-tab.active .persona-avatar { box-shadow: none; }
#chat-screen .persona-tab strong, #chat-screen .persona-tab.active strong { align-self: end; color: var(--report-ink); font-size: 16px; }
#chat-screen .persona-tab small { align-self: start; color: var(--report-meta); font-size: 11px; }
#chat-screen .screen-actions { justify-self: end; }
#chat-screen .text-button { color: #64758d; }
body.is-chat .chat-card { margin: 0 auto; width: min(100%, var(--app-max-width)); }
#chat-screen .chat-messages { gap: 10px; padding: 24px 8px 18px; }
#chat-screen .message { max-width: 92%; gap: 9px; align-items: flex-start; }
#chat-screen .message.user { justify-self: end; flex-direction: row; }
#chat-screen .message.assistant { justify-self: start; }
#chat-screen .message.grouped { margin-top: 0; }
#chat-screen .message-body { gap: 5px; }
#chat-screen .message-name { color: var(--report-meta); font-size: 13px; }
#chat-screen .bubble {
  width: fit-content; max-width: min(320px, 74vw); padding: 11px 15px;
  border-radius: 6px 20px 20px; background: var(--report-surface); color: var(--report-ink);
  font: 400 15.5px/1.55 var(--dialogue-font); letter-spacing: -.02em;
}
#chat-screen .message-body .bubble + .bubble { border-radius: 20px; }
#chat-screen .message.user .bubble { border-radius: 20px 6px 20px 20px; background: #455a76; color: #fff; }
#chat-screen .avatar { background: var(--report-surface); color: var(--report-muted); }
#chat-screen .message.user .avatar { background: #eef1f6; color: #455a76; }
.chat-act {
  max-width: min(620px, 82vw); margin: 16px 0 10px; padding: 0 4px;
  color: #8b8375; font: italic 14px/1.75 var(--dialogue-font);
}
.chat-act-row { justify-self: stretch; max-width: none; margin: 18px 34px 8px; }
.chat-act::before { content: '≡'; margin-right: 12px; color: #a59b89; font-style: normal; }
.chat-reaction {
  display: block; width: min(260px, 68vw); height: auto; margin: 2px 0 5px;
  border-radius: 6px 20px 20px; object-fit: cover; background: var(--report-surface);
  box-shadow: 0 3px 12px rgba(74,55,35,.1);
}
.chat-narration { margin: 14px 30px; padding: 0; border: 0; color: #8b8375; font-size: 14px; font-style: italic; }
#chat-screen .typing { color: var(--report-meta); }
.chat-composer { border-top: 1px solid var(--report-line); background: var(--paper, #fffdf8); }
#chat-screen .chat-form { padding: 11px 8px; border: 0; background: var(--paper, #fffdf8); backdrop-filter: none; }
#chat-screen .chat-form textarea { border: 1px solid var(--report-line); background: #fff; color: var(--report-ink); }
#chat-screen .chat-form textarea::placeholder { color: #aab2bd; }
#chat-screen .chat-form textarea:focus { border-color: #7c93b3; outline-color: rgba(69,90,118,.2); }
#chat-screen .chat-form button { background: #455a76; color: #fff; }
#chat-screen .chat-form button:hover:not(:disabled) { background: #3a4c65; }
#chat-screen .chat-form button:disabled { background: #9aa8bb; }
#chat-screen ::selection { background: rgba(69,90,118,.18); color: var(--report-ink); }

/* 세션이 없는 월화 상담은 같은 답장 자리에서 필요한 값을 한 턴씩 받는다. */
#chat-screen .chat-form.is-profile-input { display: block; padding: 12px 8px; }
.chat-onboarding { width: 100%; }
#chat-screen .chat-form > [hidden] { display: none !important; }
.chat-profile-progress { margin: 0 0 5px; color: #8b8375; font-size: 11px; }
.chat-profile-title { display: block; margin-bottom: 7px; color: #78736b; font-size: 11px; }
.chat-profile-fields { display: flex; align-items: center; gap: 7px; overflow-x: auto; scrollbar-width: none; }
.chat-profile-fields::-webkit-scrollbar { display: none; }
.chat-profile-fields > input, .chat-profile-fields > select { flex: 1 0 112px; min-width: 0; height: 42px; padding: 0 11px; border: 1px solid var(--report-line); border-radius: 11px; background: #fff; color: var(--report-ink); font-size: 14px; }
.chat-profile-date { flex: 1 0 220px; display: grid; grid-template-columns: minmax(64px, 1.5fr) auto minmax(42px, 1fr) auto minmax(42px, 1fr) auto; align-items: center; gap: 4px; color: #767d87; font-size: 12px; }
.chat-profile-date input { min-width: 0; height: 46px; padding: 0 9px; border: 1px solid var(--report-line); border-radius: 12px; background: #fff; color: var(--report-ink); font-size: 15px; text-align: center; }
.chat-profile-choice-row { flex: 0 0 112px; display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
#chat-screen .chat-form .chat-profile-choice { width: 100%; height: 44px; border: 1px solid #d5d8de; border-radius: 12px; background: #fff; color: #596371; font-size: 14px; }
#chat-screen .chat-form .chat-profile-choice.selected { border-color: #455a76; background: #455a76; color: #fff; }
.chat-profile-check { flex: 0 0 auto; display: flex; align-items: center; gap: 4px; min-height: 32px; color: #686f79; font-size: 12px; white-space: nowrap; }
#chat-screen .chat-form .chat-profile-details { grid-column: 1 / -1; width: fit-content; height: auto; padding: 0; border: 0; border-radius: 0; background: transparent; color: #64758d; font-size: 12px; text-decoration: underline; }
.chat-profile-error { min-height: 18px; margin: 7px 0 0; color: #a33b32; font-size: 12px; }
.chat-profile-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 5px; }
#chat-screen .chat-form .chat-profile-actions button { width: auto; height: 42px; flex: 0 0 auto; padding: 0 18px; border-radius: 12px; font-size: 14px; }
#chat-screen .chat-form .chat-profile-back { border: 1px solid var(--report-line); background: #fff; color: #68717d; }
#chat-screen .chat-form .chat-profile-next { min-width: 88px; background: #455a76; color: #fff; }
#chat-screen .chat-form .chat-profile-next:disabled { background: #c3c8cf; }
.chat-profile-summary { flex: 1 0 auto; margin: 0; color: var(--report-ink); font-size: 13px; white-space: nowrap; }
#chat-screen .chat-form .chat-profile-reset { border: 1px solid var(--report-line); background: #fff; color: #68717d; }

@media (max-width: 520px) {
  #chat-screen .chat-topbar { min-height: 62px; }
  #chat-screen .screen-actions .text-button { font-size: 11px; }
  #chat-screen .message { max-width: 98%; }
  #chat-screen .bubble { max-width: 72vw; }
}

/* 서책형 문답 마감 */
#chat-screen .chat-new {
  margin-right: 6px; padding: 6px 10px; border: 1px solid #d8cbb8; border-radius: 999px;
  color: #65483b; background: #fffaf1; font: 500 12px/1 var(--sans); cursor: pointer;
}
#chat-screen .chat-new:hover { border-color: #9f765f; background: #f8efe3; }
#chat-screen .chat-credit {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 10px;
  border: 1px solid #d8c8a9; border-radius: 999px; color: #6e5636; background: #f8f0df;
  font: 650 11px/1 var(--sans); white-space: nowrap; cursor: pointer;
}
#chat-screen .chat-credit:hover { border-color: #9b7440; }
#chat-screen .chat-credit:focus-visible { outline: 2px solid #8b754d; outline-offset: 3px; }
#chat-screen .chat-credit i {
  position: relative; width: 16px; height: 16px; border: 1px solid #9b7440; border-radius: 50%;
  background: #d8b772; box-shadow: inset 0 0 0 2px rgba(255,245,213,.42);
}
#chat-screen .chat-credit i::after {
  content: ""; position: absolute; inset: 5px; border: 1px solid #8d6838; background: #f8f0df;
}

/* 지문은 프롬프트 기호 없이 서책의 짧은 방백처럼 둔다. */
.chat-act-row {
  justify-self: center; max-width: min(580px, 86vw); margin: 17px auto 9px; padding: 7px 13px;
  border: 1px solid #e5dccd; border-radius: 999px; color: #8b806f; background: rgba(250,246,237,.72);
  text-align: center; font: italic 12.5px/1.65 var(--serif);
}
.chat-act::before { content: none; }
.chat-act-inline {
  max-width: none; margin: 0 0 7px; padding: 0; color: #8b806f;
  font: italic 12.5px/1.55 var(--serif);
}
.chat-act-inline + span { display: block; }

/* 연속 대사는 미색 편지 한 묶음처럼 읽히게 한다. */
#chat-screen .message.assistant .message-body { gap: 8px; }
#chat-screen .message.assistant .bubble {
  border: 1px solid #eae3da; background: #fdfbf7; box-shadow: 0 2px 8px rgba(67,48,29,.035);
}
#chat-screen .message.assistant .message-body .bubble + .bubble { margin-top: -1px; }

/* 첫 질문과 답변 뒤 후속 질문. 좁은 화면에서는 가로로 넘겨 본다. */
#chat-screen .chat-suggestions {
  display: flex; flex: 0 0 auto; gap: 8px; padding: 8px 34px 10px 8px; overflow-x: auto;
  scrollbar-width: none; scroll-snap-type: x proximity; background: var(--paper, #fffdf8);
  -webkit-mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 38px), transparent 100%);
  mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 38px), transparent 100%);
}
#chat-screen .chat-suggestions:empty { display: none; }
/* 대화 내용에 맞춰 뜨는 행동 묘사. 추천 질문과 같은 자리에 겹쳐 질문을 잠깐 덮는다. */
#chat-screen .chat-suggest-zone { display: grid; flex: 0 0 auto; }
#chat-screen .chat-suggest-zone > * { grid-area: 1 / 1; }
#chat-screen .chat-live-reaction {
  display: flex; align-items: flex-start; gap: 9px; padding: 11px 16px;
  background: var(--paper, #fffdf8); color: #8a6a55; z-index: 1; animation: appear .35s ease both;
}
#chat-screen .chat-live-reaction[hidden] { display: none; }
#chat-screen .chat-live-reaction p { margin: 0; min-width: 0; font: italic 500 13px/1.55 var(--sans); word-break: keep-all; overflow-wrap: anywhere; }
#chat-screen .chat-live-reaction b { font-style: normal; font-weight: 700; color: #65483b; }
#chat-screen .live-reaction-avatar { width: 24px; height: 24px; flex: 0 0 24px; border-radius: 50%; overflow: hidden; }
#chat-screen .live-reaction-avatar .avatar-image { width: 100%; height: 100%; object-fit: cover; }
#chat-screen .chat-suggestions::-webkit-scrollbar { display: none; }
#chat-screen .chat-suggestion {
  flex: 0 0 auto; max-width: min(78vw, 340px); padding: 9px 13px;
  border: 1px solid #d8cbb8; border-radius: 999px; color: #65483b; background: #fffaf1;
  font: 500 12px/1.45 var(--sans); white-space: nowrap; cursor: pointer; scroll-snap-align: start;
}
#chat-screen .chat-suggestion.is-followup {
  min-width: 0; box-sizing: border-box; overflow: hidden; text-overflow: ellipsis;
}
#chat-screen .chat-suggestion:hover { border-color: #9f765f; background: #f8efe3; }
/* 추천 질문은 폰과 PC 모두 한 줄 가로 스크롤이다. PC는 마우스 휠로 옆으로 못 넘기니 양 끝에 화살표 버튼을 둔다. */
#chat-screen .chat-suggest-zone { position: relative; }
#chat-screen .chat-suggest-arrow {
  display: none; position: absolute; top: 50%; z-index: 0; width: 28px; height: 28px; margin-top: -14px; padding: 0;
  place-items: center; border: 1px solid #d8cbb8; border-radius: 50%; background: #fffaf1; color: #65483b;
  font: 600 18px/1 var(--sans); cursor: pointer; box-shadow: 0 2px 6px rgba(67,48,29,.12);
}
#chat-screen .chat-suggest-arrow.is-prev { left: 4px; }
#chat-screen .chat-suggest-arrow.is-next { right: 4px; }
#chat-screen .chat-suggest-arrow:hover { background: #f8efe3; border-color: #9f765f; }
@media (hover: hover) and (pointer: fine) {
  #chat-screen .chat-suggest-arrow.is-visible { display: grid; }
  /* PC는 오른쪽이 흐려지는 대신 화살표가 넘어갈 곳을 알려 준다. 끝 칩이 화살표에 가리지 않게 오른쪽을 비운다. */
  #chat-screen .chat-suggestions { -webkit-mask-image: none; mask-image: none; padding-right: 40px; }
}

#chat-screen .chat-form textarea { border-color: #ded5c7; background: #fdfbf7; }
#chat-screen .chat-form button {
  border: 0; background: #55312d; color: #fffaf1; font: 600 23px/1 var(--sans);
  transition: background-color .16s ease, color .16s ease;
}
#chat-screen .chat-form button:hover:not(:disabled) { background: #442520; }
#chat-screen .chat-form button:disabled { background: #e5ded2; color: #aaa092; opacity: 1; cursor: default; }

@media (max-width: 390px) {
  #chat-screen .chat-credit { padding-inline: 8px; font-size: 10px; }
}

/* 무료 첫 문답 뒤의 서책형 전환 안내 */
.chat-upgrade-dialog {
  box-sizing: border-box; width: min(430px, calc(100% - 30px)); padding: 34px 26px 24px;
  border: 1px solid #d8c8aa; border-radius: 20px; color: #332a22; background: #fffaf1;
  box-shadow: 0 24px 80px rgba(45,31,20,.28); text-align: center;
}
.chat-upgrade-dialog::backdrop { background: rgba(31,24,18,.48); backdrop-filter: blur(3px); }
.chat-upgrade-close { position: absolute; top: 12px; right: 14px; border: 0; color: #8f8373; background: transparent; font-size: 25px; cursor: pointer; }
.chat-upgrade-coin { position: relative; width: 42px; height: 42px; margin: 0 auto 14px; border: 2px solid #9b7440; border-radius: 50%; background: #d8b772; box-shadow: inset 0 0 0 5px rgba(255,245,213,.38); }
.chat-upgrade-coin i { position: absolute; inset: 14px; border: 1px solid #896434; background: #fffaf1; }
.chat-upgrade-kicker { margin: 0 0 8px; color: #8b342b; font: 700 11px/1.4 var(--sans); letter-spacing: .06em; }
.chat-upgrade-dialog h2 { margin: 0; font: 700 25px/1.42 var(--serif); letter-spacing: -.04em; }
.chat-upgrade-dialog > p:not(.chat-upgrade-kicker) { margin: 16px 0 22px; color: #6d6153; font: 400 14px/1.75 var(--sans); word-break: keep-all; }
.chat-upgrade-cta { display: grid; justify-items: center; gap: 5px; box-sizing: border-box; width: 100%; margin: 0 auto; padding: 15px 18px; border: 0; border-radius: 12px; color: #fffaf1; background: #55312d; font: 700 15px/1.35 var(--serif); text-align: center; text-decoration: none; cursor: pointer; }
.chat-upgrade-cta b { color: #ead0a1; font: 700 12px/1.3 var(--sans); }
.chat-upgrade-later { display: block; margin: 12px auto 0; padding: 7px 14px; border: 0; color: #918676; background: transparent; font: 500 12px/1.4 var(--sans); text-align: center; cursor: pointer; }

/* 상담 상대를 고르는 메신저 목록 */
body:has(#chat-list-screen.active) .shell { padding-top: 0; }
body:has(#chat-list-screen.active) .site-footer { display: none; }
#chat-list-screen { max-width: 720px; margin: 0 auto; color: var(--report-ink, #292d34); padding: 0 0 40px; }
.chat-list-heading { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 0; }
.chat-list-heading button { min-height: 44px; cursor: pointer; }
.chat-list-heading h2 { margin: 0; font: 700 27px/1.35 var(--serif); letter-spacing: -.04em; }
.chat-list-heading > span { margin-left: auto; color: #93908b; font-size: 12px; }
.chat-room-list { display: grid; gap: 10px; }
.chat-room { display: flex; align-items: center; gap: 16px; width: 100%; padding: 20px 16px; border: 1px solid #e8e4dc; border-radius: 14px; background: #fff; box-shadow: 0 3px 12px rgba(55,45,34,.04); text-align: left; cursor: pointer; color: inherit; }
.chat-room:hover { border-color: #dcd4c8; background: #fff; box-shadow: 0 5px 16px rgba(55,45,34,.07); }
.chat-room:focus-visible { outline: 2px solid #8b754d; outline-offset: 2px; }
.chat-room-avatar { width: 62px; height: 62px; flex: 0 0 62px; border-radius: 22px; background: #e8edf1; overflow: hidden; }
.chat-room-wolhwa .chat-room-avatar { display: grid; place-items: center; background: #efe4d9; color: #92745a; font: 600 25px var(--serif, serif); }
.chat-room-copy { display: grid; gap: 7px; min-width: 0; flex: 1; }
.chat-room-copy strong { font: 600 17px/1.3 var(--sans); }
.chat-room-copy > .chat-room-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; min-width: 0; overflow: visible; color: inherit; font-size: inherit; }
.chat-room-head strong { min-width: 0; }
.chat-room-time { flex: 0 0 auto; color: #a39d92; font: 500 12px/1.5 var(--sans); white-space: nowrap; }
.chat-room-time:empty { display: none; }
.chat-room-copy > span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--ui-muted); font-size: 14px; line-height: 1.6; }
.chat-room-copy > .chat-room-desc.has-preview { color: #4f4b44; font-weight: 500; }
.chat-room-copy small { color: var(--ui-muted); font-size: 13px; }
.chat-room-copy > .chat-room-discount-banner { display: block; justify-self: start; padding: 5px 10px; border: 1px solid #ead3a5; border-radius: 7px; background: #fff3d9; color: #8a5725; font-size: 12px; font-weight: 700; line-height: 1.4; overflow: visible; }
.chat-room-juwol-human:disabled { cursor: not-allowed; border-color: #d9c8ae; background: #f7f0e5; opacity: 1; }
.chat-room-juwol-human:disabled:hover { border-color: #d9c8ae; background: #f7f0e5; box-shadow: 0 3px 12px rgba(55,45,34,.04); }
.chat-room-juwol-human .chat-room-avatar { border-radius: 18px; }
.chat-room-juwol-human .avatar-image { width: 100%; height: 100%; object-fit: cover; object-position: 70% 46%; transform: scale(1.5); transform-origin: 70% 46%; }
.chat-room-juwol-human .chat-room-copy small { color: #8c6e53; font-weight: 600; }
.chat-room-arrow { color: #aaa297; font-size: 24px; }
/* 안 읽은 대화 수. 목록 오른쪽 화살표 옆에 둥근 숫자로 단다. */
.chat-room-unread { flex: 0 0 auto; display: grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: #c4543f; color: #fff; font: 700 12px/1 var(--sans); }
.chat-room-unread[hidden] { display: none; }
.chat-list-daily { margin: 28px 0 0; padding: 18px; border-radius: 14px; background: #f4efe5; color: #88744f; font-size: 13px; line-height: 1.9; }
.chat-list-daily small { color: #969085; font-size: 12px; }
#chat-list-status { font-size: 14px; line-height: 1.7; }

/* 채팅 목록 오른쪽 위의 엽전 지갑 — 채팅방 상단의 엽전 표시와 같은 엽전 모양 */
.chat-list-heading .chat-coin-chip {
  margin-left: auto; display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px;
  border: 1px solid #d8c8a9; border-radius: 999px; color: #6e5636; background: #f8f0df;
  font: 650 12px/1 var(--sans); white-space: nowrap;
}
.chat-list-heading .chat-coin-chip[hidden] { display: none; }
/* 지금 대화 상대(열릴 명식): 엽전 칩 왼쪽의 두 줄 칩. 이름 아래에 사주 네 기둥. */
.chat-list-heading .chat-list-subject { margin-left: 0; display: inline-flex; flex-direction: column; gap: 3px; min-width: 0; max-width: 132px; padding: 6px 11px; border: 1px solid #e0d6c4; border-radius: 12px; background: rgba(255, 253, 248, .7); color: #6e5636; white-space: nowrap; }
.chat-list-heading .chat-list-subject[hidden] { display: none; }
.chat-list-heading .chat-list-subject { text-align: left; cursor: pointer; }
.chat-list-heading .chat-list-subject:hover { border-color: #cbb994; background: #fffdf8; }
.chat-list-heading .chat-list-subject:focus-visible { outline: 2px solid #8b754d; outline-offset: 2px; }
.chat-list-heading .chat-list-subject strong::after { content: ' ▾'; color: #b5a78a; font-size: 9px; }
.chat-list-heading .chat-list-subject strong { overflow: hidden; text-overflow: ellipsis; font: 700 12px/1.2 var(--sans); color: #4a3a22; }
.chat-list-heading .chat-list-subject small { overflow: hidden; text-overflow: ellipsis; font: 500 12px/1.5 var(--sans); letter-spacing: -.01em; color: #8d7b5f; }
.chat-list-heading .chat-list-subject:not([hidden]) + .chat-coin-chip { margin-left: 0; }
/* 좁은 화면: 간격과 여백을 줄여 네 기둥이 다 보이게 한다. */
@media (max-width: 360px) {
  .chat-list-heading { gap: 8px; }
  .chat-list-heading button { padding-right: 4px; }
  .chat-list-heading .chat-list-subject { max-width: none; padding: 6px 8px; }
  .chat-list-heading .chat-list-subject small { font-size: 12px; letter-spacing: -.01em; }
  .chat-list-heading .chat-coin-chip { padding: 7px 9px; gap: 5px; }
}
.chat-list-heading .chat-coin-chip i {
  position: relative; width: 16px; height: 16px; border: 1px solid #9b7440; border-radius: 50%;
  background: #d8b772; box-shadow: inset 0 0 0 2px rgba(255,245,213,.42);
}
.chat-list-heading .chat-coin-chip i::after { content: ""; position: absolute; inset: 5px; border: 1px solid #8d6838; background: #f8f0df; }
.chat-list-heading .chat-coin-chip b { color: #4a3a22; font-size: 14px; font-weight: 800; }
.chat-list-heading .chat-coin-chip small { padding: 3px 6px; border-radius: 99px; color: #fbf3e4; background: #6e2c24; font-size: 10px; font-weight: 700; }

/* 채팅은 로그인한 사람만. 로그인 전에는 방 목록 대신 이 안내가 뜬다. */
.chat-list-offering { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 8px; padding: 10px 14px; border: 1px solid #ead3a5; border-radius: 10px; background: #fff3d9; color: #8a5725; font-size: 13px; font-weight: 700; line-height: 1.45; text-decoration: none; }
.chat-list-offering span { flex: none; color: #6f4418; font-weight: 800; }
.chat-list-login { display: grid; justify-items: center; gap: 8px; margin-top: 8px; padding: 36px 18px; border: 1px solid var(--ui-line); border-radius: 16px; background: #fffdf8; text-align: center; }
.chat-list-login[hidden] { display: none; }
.chat-list-login strong { font: 700 19px/1.4 var(--serif); color: #2a241f; }
.chat-list-login p { margin: 0; color: #7a7062; font: 400 15px/1.75 var(--sans); word-break: keep-all; }
.chat-list-login a { margin-top: 10px; padding: 13px 22px; border-radius: 10px; color: #191600; background: #fee500; font: 700 14px/1 var(--sans); text-decoration: none; }
.chat-list-login .chat-list-login-hint { margin-top: 6px; font-size: 13px; }
.chat-list-login .chat-list-login-hint a { margin: 0; padding: 0; border-radius: 0; background: none; color: #6b4e2e; font: inherit; text-decoration: underline; }
.chat-list-daily[hidden], .chat-room-list[hidden] { display: none; }

/* 대화 화면의 날짜 구분선과 말풍선 옆 시각(카톡처럼) */
#chat-screen .chat-date-divider { display: flex; justify-content: center; margin: 18px 0 8px; }
#chat-screen .chat-date-divider span { padding: 5px 14px; border-radius: 999px; background: rgba(120, 110, 95, .14); color: #766f63; font: 500 12px/1.4 var(--sans); }
#chat-screen .chat-time { flex: 0 0 auto; align-self: flex-end; padding-bottom: 3px; color: #a39d92; font: 500 11px/1.2 var(--sans); white-space: nowrap; }
#chat-screen .bubble-row { display: flex; align-items: flex-end; gap: 6px; min-width: 0; }
/* 시각이 옆에 붙는 만큼 말풍선이 좁아진다. */
#chat-screen .bubble-row .bubble, #chat-screen .message.user .bubble { max-width: min(320px, calc(100vw - 150px)); }

/* 대화할 명식 고르기(아래에서 올라오는 시트) */
.chat-subject-dialog { width: min(440px, 100vw); max-width: 100vw; max-height: 78vh; margin: auto auto 0; padding: 18px 16px calc(16px + env(safe-area-inset-bottom, 0px)); border: 0; border-radius: 22px 22px 0 0; background: #fffdf8; color: #3a342c; overflow: hidden; }
.chat-subject-dialog[open] { display: flex; flex-direction: column; }
.chat-subject-dialog::backdrop { background: rgba(31, 24, 18, .48); backdrop-filter: blur(3px); }
.chat-subject-dialog header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.chat-subject-dialog h2 { margin: 0; font: 700 20px/1.4 var(--serif, serif); letter-spacing: -.03em; }
.chat-subject-dialog header button { width: 36px; height: 36px; border: 0; border-radius: 50%; background: #f1ebde; color: #6e5636; font-size: 22px; line-height: 1; cursor: pointer; }
.chat-subject-list { display: grid; gap: 8px; margin: 14px 0 0; padding: 0; list-style: none; overflow-y: auto; }
.chat-subject-option { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 13px 14px; border: 1px solid #e8e0d0; border-radius: 14px; background: #fff; color: inherit; text-align: left; cursor: pointer; }
.chat-subject-option:hover { border-color: #cbb994; }
.chat-subject-option.is-current { border-color: #55312d; background: #fbf6ee; box-shadow: inset 0 0 0 1px #55312d; }
.chat-subject-main { display: grid; gap: 3px; min-width: 0; }
.chat-subject-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 700 15px/1.3 var(--sans); }
.chat-subject-main em { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: normal 500 12px/1.3 var(--sans); color: #7a7368; }
.chat-subject-main small { font: 500 12px/1.5 var(--sans); letter-spacing: -.01em; color: #9a8a6e; }
.chat-subject-side { flex: 0 0 auto; color: #a39d92; font: 500 12px/1.5 var(--sans); white-space: nowrap; }
.chat-subject-option.is-current .chat-subject-side { color: #55312d; font-weight: 700; }
#chat-subject-status { min-height: 0; margin: 10px 0 0; color: #8b8375; font-size: 13px; }
#chat-subject-status:empty { display: none; }
.chat-subject-new { margin-top: 12px; padding: 12px; border: 1px dashed #d4c7ab; border-radius: 14px; background: transparent; color: #6e5636; font: 600 14px/1.2 var(--sans); cursor: pointer; }

/* 장면 사진(600×450)과 행동 묘사. 사진은 늘 같은 비율이라 먼저 떠도 아래 말풍선이 밀려나지 않는다. */
#chat-screen .chat-scene-photo { width: min(260px, 68vw); height: auto; aspect-ratio: 4 / 3; object-fit: cover; }
#chat-screen .chat-scene-act { display: block; margin: 3px 4px 5px; font: italic 500 14.5px/1.65 var(--sans); color: #4f5866; }
#chat-screen .chat-scene-closing { margin-top: 6px; }

/* 채팅 중에는 사이트 헤더(로고·공지·메뉴)를 걷고, 주월 뒤로가기 바가 맨 위에 오게 한다. 바 높이도 줄인다. */
body.is-chat .site-header,
body.is-chat .site-menu-button,
body.is-chat .site-notice-button { display: none; }
body.is-chat #chat-screen.active { top: 0; }
body.is-chat #chat-screen .chat-topbar {
  min-height: 48px; padding: max(5px, env(safe-area-inset-top)) 12px 5px 6px;
  grid-template-columns: 34px 1fr auto; gap: 4px;
}
body.is-chat #chat-screen .chat-back { font-size: 32px; line-height: 1; width: 34px; height: 38px; }
body.is-chat #chat-screen .persona-tab,
body.is-chat #chat-screen .persona-tab.active { grid-template-columns: 32px 1fr; column-gap: 8px; }
body.is-chat #chat-screen .persona-avatar { width: 32px; height: 32px; }
body.is-chat #chat-screen .persona-tab strong,
body.is-chat #chat-screen .persona-tab.active strong { font-size: 15px; line-height: 1.25; }
body.is-chat #chat-screen .persona-tab small { font-size: 10.5px; line-height: 1.25; }
body.is-chat #chat-screen .screen-actions { gap: 6px; }
body.is-chat #chat-screen .chat-new { padding: 4px 9px; font-size: 11.5px; }
body.is-chat #chat-screen .chat-credit { padding: 4px 9px; font-size: 11.5px; }
/* 상단바 오른쪽의 새 대화·엽전은 세로로 쌓지 않고 한 줄에 둔다. */
body.is-chat #chat-screen .screen-actions { display: flex; flex-direction: row; align-items: center; flex-wrap: nowrap; white-space: nowrap; }
/* 채팅 목록은 하단 탭으로 오가므로 뒤로가기를 두지 않는다. */
#chat-list-back { display: none; }

/* 마지막 말풍선·행동과 추천 질문 사이 간격을 줄인다. */
body.is-chat #chat-screen .chat-messages { padding-bottom: 8px; }
body.is-chat #chat-screen .chat-suggestions { padding-top: 2px; padding-bottom: 8px; }
/* 입력창을 낮춘다(48 → 40px). 바깥 여백과 보내기 버튼도 같이 줄인다. */
body.is-chat #chat-screen .chat-form { padding: 7px 8px; gap: 8px; }
body.is-chat #chat-screen .chat-form textarea { min-height: 40px; padding: 9px 16px; font-size: 15px; line-height: 1.45; border-radius: 20px; }
body.is-chat #chat-screen .chat-form button { width: 40px; height: 40px; flex-basis: 40px; font-size: 18px; }
/* 안드로이드에서 입력창에 스크롤바가 뜨지 않게 한다. 높이는 JS가 글 길이에 맞춰 정한다. */
#chat-screen .chat-form textarea { overflow-y: hidden; scrollbar-width: none; -ms-overflow-style: none; }
#chat-screen .chat-form textarea::-webkit-scrollbar { display: none; width: 0; height: 0; }
/* 상단바의 주월 얼굴이 위로 치우쳐 보였다. 얼굴을 바 한가운데에 둔다. */
body.is-chat #chat-screen .persona-tab,
body.is-chat #chat-screen .persona-tab.active { align-items: center; align-content: center; }
body.is-chat #chat-screen .persona-avatar { align-self: center; }

/* 장소 배경: 글이 읽히도록 옅은 흰 막을 덮는다. */
#chat-screen.has-place { position: relative; isolation: isolate; }
#chat-bg { position: absolute; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
#chat-bg > div { position: absolute; inset: 0; background-size: cover; background-position: center; opacity: 0; transition: opacity .8s ease; }
#chat-bg > div.is-on { opacity: 1; }
#chat-bg::after { content: ""; position: absolute; inset: 0; background: rgba(255,253,248,.84); }
@media (prefers-reduced-motion: reduce) { #chat-bg > div { transition: none; } }
#chat-screen .chat-move { margin-bottom: 6px; color: #6b4f1f; }
#chat-screen .chat-invite { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 4px 0 2px; }
#chat-screen .chat-invite .chat-scene-act { flex-basis: 100%; margin: 0; }
#chat-screen .chat-invite button { padding: 8px 14px; border: 1px solid #2f3947; border-radius: 999px; background: #2f3947; color: #f6f2e8; font: 600 13px/1.2 var(--sans); cursor: pointer; }
#chat-screen .chat-invite button.is-quiet { border-color: #d5d8de; background: #fff; color: #8b929d; font-weight: 500; }

/* 효과음·진동 토글, iOS용 흔들림 */
#chat-screen .chat-fx-toggle { display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0; background: transparent; color: #4f5866; cursor: pointer; }
#chat-screen .chat-fx-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
#chat-screen .chat-fx-toggle .fx-slash { display: none; }
#chat-screen .chat-fx-toggle.is-off { color: #a3aab5; }
#chat-screen .chat-fx-toggle.is-off .fx-slash { display: block; }
#chat-screen .chat-fx-toggle.is-off .fx-waves { display: none; }
#chat-screen.fx-shake { animation: fx-shake .18s linear 1; }
@keyframes fx-shake { 0%,100% { transform: translateX(0); } 15% { transform: translateX(-4px); } 45% { transform: translateX(4px); } 75% { transform: translateX(-2px); } }

/* 입력창 위 반응 얼굴: 바 높이는 그대로 두고, 얼굴만 왼쪽 끝에서 크게 위로 튀어나오게 */
#chat-screen .chat-live-reaction:has(.live-face) { position: relative; min-height: 44px; padding-left: 88px; }
#chat-screen .live-face { position: absolute; left: 12px; bottom: 3px; z-index: 2; width: 66px; height: 66px; border-radius: 50%; overflow: hidden; background: #f3ede2; box-shadow: 0 0 0 3px #fff, 0 0 0 4px rgba(139,109,59,.4), 0 3px 10px rgba(60,40,20,.22); }
#chat-screen .live-face img { position: absolute; max-width: none; height: auto; transition: opacity .25s ease; }
#chat-screen .chat-live-reaction p { font-size: 13.5px; }

/* 하단 영역(질문바·반응바·입력 바)도 상단 바처럼 화면 양끝까지: 대화방 좌우 여백 14px을 걷어 낸다 */
body.is-chat #chat-screen .chat-suggest-zone,
body.is-chat #chat-screen .chat-composer { margin-left: -14px; margin-right: -14px; }
/* 스냅이 첫 칩을 왼쪽 끝에 붙이지 않도록 스냅 여백도 같이 준다 */
body.is-chat #chat-screen .chat-suggestions { padding-left: 18px; scroll-padding-left: 18px; }
body.is-chat #chat-screen .chat-form { padding: 7px 14px; }
#chat-screen .chat-place-name { margin-top: 2px; font-style: normal; font-weight: 600; color: #6b4f1f; }

/* ── 보기 방식: 소설형 ─────────────────────────────────────────
   말풍선·아바타 없이 글이 그대로 흐른다. 지문은 흐리게, 대사는 진하게, 장면 이미지는 가로로 꽉 채운다.
   내 말은 구분선 사이에 평문으로 둔다. DOM은 그대로고 CSS만 바꾼다(#chat-screen.view-novel). */
#chat-screen.view-novel .chat-messages { gap: 0; padding: 0 18px 28px; }
#chat-screen.view-novel .message,
#chat-screen.view-novel .message.user { display: block; max-width: none; gap: 0; margin: 0; justify-self: stretch; }
#chat-screen.view-novel .chat-messages .message.grouped { margin-top: 0; }
#chat-screen.view-novel .message .avatar,
#chat-screen.view-novel .message-name { display: none; }
#chat-screen.view-novel .message-body { display: block; padding: 0; }
#chat-screen.view-novel .bubble-row { display: block; }
#chat-screen.view-novel .bubble,
#chat-screen.view-novel .message.user .bubble {
  max-width: none; margin: 0 0 14px; padding: 0; border-radius: 0; background: none;
  color: var(--report-ink); font: 400 16px/1.9 var(--dialogue-font, var(--sans)); letter-spacing: -.02em;
}
#chat-screen.view-novel .chat-act-inline { display: block; margin: 0 0 4px; color: #8a909b; font: 400 15.5px/1.85 var(--sans); font-style: normal; }
#chat-screen.view-novel .chat-act-inline + span { display: block; }
#chat-screen.view-novel .chat-scene-act { margin: 0 0 14px; color: #8a909b; font: 400 15.5px/1.85 var(--sans); font-style: normal; }
#chat-screen.view-novel .chat-move, #chat-screen.view-novel .chat-bond-up, #chat-screen.view-novel .chat-place-name { margin-bottom: 14px; }
#chat-screen.view-novel .chat-scene-photo {
  display: block; width: calc(100% + 36px); max-width: none; margin: 0 0 16px -18px; aspect-ratio: 4 / 3; border-radius: 0; object-fit: cover;
}
#chat-screen.view-novel .message.user {
  margin: 10px 0 18px; padding: 20px 0; border-top: 1px solid var(--report-line); border-bottom: 1px solid var(--report-line);
}
#chat-screen.view-novel .message.user .bubble { margin: 0; font-size: 17px; font-weight: 500; }
#chat-screen.view-novel .message.user .bubble + .bubble { margin-top: 8px; }
#chat-screen.view-novel .chat-date-divider { margin: 22px 0 14px; }
#chat-screen.view-novel .typing { padding-left: 18px; }

/* 소설형: 말풍선 완전 제거. 주월 말풍선 전용 규칙(.message.assistant .bubble)보다 우선순위를 높인다. */
#chat-screen.view-novel .message .bubble,
#chat-screen.view-novel .message.assistant .bubble,
#chat-screen.view-novel .message.user .bubble,
#chat-screen.view-novel .message.assistant .message-body .bubble + .bubble {
  width: auto; max-width: none; padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none;
}

/* 소설형 어두운 테마: 순검정이 아니라 한 단계만 낮춘 짙은 회색. 변수를 바꾸면 변수를 쓰는 규칙은 따라오고, 하드코딩된 밝은 색만 아래에서 덮는다. */
#chat-screen.view-novel {
  --paper: #23262c; --report-ink: #e8e5de; --report-muted: #a0a6b0; --report-meta: #8c929d;
  --report-line: #353a44; --report-surface: #2b2f37; color-scheme: dark;
}
body.is-chat:has(#chat-screen.view-novel.active) { background: #1b1d21; }
#chat-screen.view-novel .chat-topbar { background: rgba(35,38,44,.96); }
#chat-screen.view-novel .persona-sub i { background: #3a3f49; }
#chat-screen.view-novel .chat-fx-toggle { color: #b8bec9; }
#chat-screen.view-novel .chat-fx-toggle.is-off { color: #5f6570; }
#chat-screen.view-novel .chat-new { border-color: #3d424d; background: #2b2f37; color: #d9d4c8; }
#chat-screen.view-novel .chat-credit { border-color: #4a4538; background: #2e2b24; color: #d8c49a; }
#chat-screen.view-novel .chat-suggestion { border-color: #3d424d; background: #2b2f37; color: #d9d4c8; }
#chat-screen.view-novel .chat-suggestion:hover { border-color: #6b7280; background: #323741; }
#chat-screen.view-novel .chat-live-reaction { color: #c9b79f; }
#chat-screen.view-novel .chat-live-reaction b { color: #e0cfb5; }
#chat-screen.view-novel .live-face { background: #343942; box-shadow: 0 0 0 3px #23262c, 0 0 0 4px rgba(210,180,122,.45), 0 3px 10px rgba(0,0,0,.4); }
#chat-screen.view-novel .chat-form { background: rgba(35,38,44,.94); }
#chat-screen.view-novel .chat-form textarea { border-color: #3d424d; background: #2c3038; color: #e8e5de; }
#chat-screen.view-novel .chat-form textarea::placeholder { color: #7d838e; }
#chat-screen.view-novel .chat-form button { background: #3b4a66; color: #fff; }
#chat-screen.view-novel .chat-form button:disabled { background: #3a3f49; color: #7d838e; }
#chat-screen.view-novel .chat-date-divider span { background: rgba(255,255,255,.07); color: #a39d92; }
#chat-screen.view-novel .chat-move, #chat-screen.view-novel .chat-bond-up, #chat-screen.view-novel .chat-place-name { color: #d2b47a; }
#chat-screen.view-novel .chat-invite button { border-color: #d2b47a; background: #d2b47a; color: #23262c; }
#chat-screen.view-novel .chat-invite button.is-quiet { border-color: #3d424d; background: transparent; color: #a0a6b0; }
#chat-screen.view-novel #chat-bg::after { background: rgba(27,29,33,.86); }
#chat-screen.view-novel .chat-act-inline, #chat-screen.view-novel .chat-scene-act { color: #8f95a0; }
#chat-screen.view-novel .chat-move { color: #d2b47a; }
#chat-screen.view-novel .chat-suggest-arrow { border-color: #3d424d; background: #2b2f37; color: #d9d4c8; box-shadow: none; }
#chat-screen .chat-fx-toggle .fx-half { fill: currentColor; }
#chat-screen #chat-view.is-off { color: #4f5866; }
#chat-screen.view-novel #chat-view.is-off { color: #b8bec9; }
#chat-screen.view-novel #chat-view svg { transform: scaleX(-1); }

/* 소설형 시각: 글 아래에 작고 옅게 */
#chat-screen.view-novel .message.user { display: flex; flex-direction: column; align-items: stretch; }
#chat-screen.view-novel .message.user .chat-time { order: 99; margin-top: 8px; }
#chat-screen.view-novel .bubble-row { display: flex; flex-direction: column; align-items: flex-start; }
#chat-screen.view-novel .bubble-row .chat-time { margin: -8px 0 14px; }
#chat-screen.view-novel .chat-time { padding: 0; color: #7d838e; font: 400 10.5px/1.2 var(--sans); letter-spacing: 0; }

/* ── 주월 캐릭터카드 ── */
#chat-screen .avatar.is-card { cursor: pointer; }
#chat-screen .avatar.is-card:hover { box-shadow: 0 0 0 2px rgba(185,152,90,.55); }
.cheong-card-overlay { position: absolute; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; background: rgba(20,18,16,.55); animation: appear .2s ease both; }
.cheong-card {
  position: relative; width: 100%; max-height: 88%; overflow-y: auto; overscroll-behavior: contain; padding: 0 0 28px;
  border-radius: 20px 20px 0 0; background: var(--paper, #fffdf8); color: var(--report-ink, #2d302d); font: 400 14px/1.7 var(--sans);
  animation: card-up .28s ease both;
}
@keyframes card-up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.cheong-card .card-close { position: absolute; top: 10px; right: 12px; z-index: 2; width: 32px; height: 32px; border: 0; border-radius: 50%; background: rgba(0,0,0,.45); color: #fff; font: 300 22px/1 var(--sans); cursor: pointer; }
.cheong-card .card-hero { height: 190px; overflow: hidden; border-radius: 20px 20px 0 0; background: #e9e1d2; }
.cheong-card .card-hero img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 28%; display: block; }
.cheong-card .card-head { padding: 14px 20px 4px; }
.cheong-card h2 { margin: 0; font: 700 24px/1.3 var(--sans); letter-spacing: -.03em; }
.cheong-card h2 small { color: var(--report-meta, #8b929d); font: 500 14px/1 var(--sans); }
.cheong-card .card-title { margin: 2px 0 8px; color: var(--report-muted, #6b7280); }
.cheong-card .card-facts { display: flex; flex-wrap: wrap; gap: 6px; }
.cheong-card .card-facts span { padding: 3px 10px; border: 1px solid var(--report-line, #e3e0d8); border-radius: 999px; color: var(--report-muted, #6b7280); font-size: 12px; }
.cheong-card .card-section { padding: 16px 20px 0; }
.cheong-card h3 { margin: 0 0 6px; color: #8a6420; font: 700 12px/1.4 var(--sans); letter-spacing: .06em; }
.cheong-card .card-list { margin: 0; padding-left: 18px; }
.cheong-card .card-list li { margin: 3px 0; }
.cheong-card .card-story { margin: 0 0 6px; }
.cheong-card .card-muted { margin: 0; color: var(--report-meta, #8b929d); }
.cheong-card .card-bond { margin: 0 0 8px; font-weight: 600; }
.cheong-card .card-gauge { height: 6px; border-radius: 3px; background: var(--report-line, #e6e9ef); overflow: hidden; }
.cheong-card .card-gauge b { display: block; height: 100%; background: #b9985a; }
.cheong-card .card-ladder { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; padding: 0; list-style: none; }
.cheong-card .card-ladder li { padding: 4px 11px; border: 1px dashed var(--report-line, #ccc); border-radius: 999px; color: var(--report-meta, #8b929d); font-size: 12.5px; }
.cheong-card .card-ladder li.is-reached { border-style: solid; color: var(--report-ink, #2d302d); }
.cheong-card .card-ladder li.is-now { border-color: #b9985a; background: rgba(185,152,90,.16); font-weight: 700; }
.cheong-card .card-places { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.cheong-card .card-places li { display: flex; gap: 12px; align-items: center; }
.cheong-card .card-places img { flex: 0 0 64px; width: 64px; height: 64px; border-radius: 10px; object-fit: cover; }
.cheong-card .card-places strong { display: block; font-size: 14px; }
.cheong-card .card-places span, .cheong-card .card-places em { display: block; color: var(--report-muted, #6b7280); font-size: 12.5px; font-style: normal; line-height: 1.5; }
.cheong-card .card-places li.is-locked img { filter: grayscale(1) brightness(.6) blur(2px); }
.cheong-card .card-places li.is-locked strong { color: var(--report-meta, #8b929d); }
@media (min-width: 521px) { .cheong-card-overlay { align-items: center; } .cheong-card { max-width: 420px; border-radius: 20px; } .cheong-card .card-hero { border-radius: 20px 20px 0 0; } }
#chat-screen .chat-bubble-act { color: #7b818c; font-style: italic; font-size: .93em; }
#chat-screen.view-novel .chat-bubble-act { color: #8f95a0; font-style: normal; }
#chat-screen .chat-scene-act + .chat-scene-act { margin-top: -1px; }

/* 말풍선 속 지문/대사 나눔 */
#chat-screen.view-novel .chat-bubble-act { display: block; margin: 0 0 8px; font-size: 15.5px; line-height: 1.85; color: #8f95a0; font-style: normal; }
#chat-screen.view-novel .chat-bubble-say { display: block; color: var(--report-ink); }
#chat-screen.view-novel .chat-bubble-say::before { content: "\201C"; }
#chat-screen.view-novel .chat-bubble-say::after { content: "\201D"; }
#chat-screen.view-novel .chat-bubble-act + .chat-bubble-say { margin-top: 2px; }
#chat-screen .chat-bubble-narr { margin: 2px 4px 6px; }
#chat-screen .message-body > .chat-bubble-narr:not(:first-child) { margin-top: 6px; }

/* 캐릭터카드 사주표 */
.cheong-card .card-birth { margin: 0 0 8px; font-weight: 600; }
.cheong-card .card-chart { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 4px 0 8px; }
.cheong-card .card-pillar { display: grid; gap: 4px; justify-items: center; padding: 8px 4px; border: 1px solid var(--report-line, #e3e0d8); border-radius: 10px; }
.cheong-card .card-pillar.is-day { border-color: #b9985a; background: rgba(185,152,90,.12); }
.cheong-card .card-pillar-label { color: var(--report-meta, #8b929d); font-size: 11.5px; }
.cheong-card .card-pillar-char { display: grid; justify-items: center; line-height: 1.1; }
.cheong-card .card-pillar-char b { font: 700 26px/1.1 var(--serif, serif); }
.cheong-card .card-pillar-char small { color: var(--report-muted, #6b7280); font-size: 11px; }
.cheong-card .card-elements { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 6px; font-size: 12.5px; font-weight: 600; }
.cheong-card .wood { color: #4f8a5b; } .cheong-card .fire { color: #c4574a; } .cheong-card .earth { color: #a8812f; } .cheong-card .metal { color: #7d8794; } .cheong-card .water { color: #3f6fa6; }

/* 채팅 목록 아래에 깔리는 캐릭터카드: 오버레이가 아니라 페이지 안의 카드 */
.cheong-card.is-inline { position: static; max-width: none; max-height: none; margin: 18px 0 28px; padding-bottom: 22px; overflow: visible; overflow: clip; overscroll-behavior: auto; touch-action: auto; border: 1px solid #e3ddd0; border-radius: 18px; background: #fffdf8; color: #2d302d; animation: none; box-shadow: 0 2px 10px rgba(67,48,29,.05); }
.cheong-card.is-inline .card-hero { border-radius: 0; }
/* 목록 아래 카드는 스크롤 컨테이너가 아니다(모달 카드의 overscroll-behavior: contain 이 터치 스크롤을 가두지 않게). 모서리는 clip 으로 자른다. */
.cheong-card.is-inline .card-hero { border-radius: 18px 18px 0 0; }

/* 주월 카드 상단 탭: 본채 / 툇마루 */
.cheong-card .card-tabs { display: flex; gap: 6px; margin: 12px 20px 0; padding: 4px; border-radius: 999px; background: rgba(120, 100, 60, .1); }
.cheong-card .card-tab { flex: 1; padding: 8px 6px; border: 0; border-radius: 999px; background: none; color: #7a6a48; font: 600 13px/1.2 var(--sans); cursor: pointer; }
.cheong-card .card-tab.is-on { background: #fffdf8; color: #3d2f14; box-shadow: 0 1px 3px rgba(60, 45, 20, .15); }
.cheong-card .card-panel[hidden] { display: none; }
.cheong-card .card-chapters { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.cheong-card .card-chapters li { display: grid; gap: 3px; padding: 10px 12px; border: 1px solid var(--report-line, #e3e0d8); border-radius: 12px; }
.cheong-card .card-chapters li.is-now { border-color: #b9985a; background: rgba(185, 152, 90, .12); }
.cheong-card .card-chapters li.is-locked { opacity: .6; }
.cheong-card .card-chapters strong { font-size: 14px; }
.cheong-card .card-chapters span, .cheong-card .card-chapters em { color: var(--report-muted, #6b7280); font-size: 12.5px; font-style: normal; line-height: 1.55; }
.cheong-card .card-chapters em { color: #8a6420; font-weight: 600; }

/* 월화문답 제목 밑 안내 한 줄(헤더 줄 아래에 따로 둔다) */
.chat-list-sub { margin: -10px 0 14px; color: #9a7650; font: 600 12px/1.4 var(--sans); letter-spacing: -.01em; }

/* 서술자 블록(◈): 말풍선 밖의 3인칭 서술. 먹빛으로 톤다운한 기울임 글씨 */
#chat-screen .chat-narration { display: flex; gap: 9px; margin: 10px 4px 8px; font: italic 400 14px/1.8 var(--sans); color: #6f6a5c; }
#chat-screen .chat-narration-mark { flex: 0 0 auto; font-style: normal; color: #a08a5a; line-height: 1.8; }
#chat-screen.view-novel .chat-narration { color: #8f95a0; font-size: 15px; }
#chat-screen.view-novel .chat-narration-mark { color: #8a7d5f; }

.toema-mission { flex: 0 0 auto; border-bottom: 1px solid var(--report-line, #e3e0d8); background: rgba(185,152,90,.10); }
.toema-mission[hidden] { display: none; }
.toema-mission-summary { display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 14px; list-style: none; cursor: pointer; }
.toema-mission-summary::-webkit-details-marker { display: none; }
.toema-mission-summary::after { content: '⌄'; flex: 0 0 auto; color: var(--report-muted, #6b7280); }
.toema-mission-details[open] .toema-mission-summary::after { transform: rotate(180deg); }
.toema-mission-title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.toema-mission-progress { flex: 0 0 auto; font-size: 12px; white-space: nowrap; color: var(--report-muted, #6b7280); }
.toema-mission-content { padding: 0 14px 10px; }
.toema-mission-content p { margin: 0 0 6px; font-size: 13px; line-height: 1.5; }
.toema-mission-content small { color: var(--report-muted, #6b7280); font-size: 12px; line-height: 1.5; }
.toema-mission-complete { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; }
.toema-mission button { flex: 0 0 auto; padding: 6px 8px; border-radius: 8px; font-size: 12px; }
.toema-reward-dialog { max-width: 380px; width: calc(100% - 40px); border: 1px solid #b9985a; border-radius: 18px; padding: 18px; }
.toema-reward-dialog::backdrop { background: rgba(0,0,0,.45); }
.toema-reward-card { border: 1px solid #b9985a; border-radius: 14px; padding: 14px; background: #faf5e9; color: #413326; }
.toema-reward-card img { width: 100%; max-height: 220px; object-fit: cover; border-radius: 9px; }
.toema-reward-card h3 { margin: 12px 0 6px; }
.toema-reward-card p { line-height: 1.65; }
.toema-reward-dialog > button { display: block; margin: 12px auto 0; padding: 8px 24px; color: #413326; background: #faf5e9; border: 1px solid #b9985a; border-radius: 9px; cursor: pointer; }

/* 스튜디오 작품 소개를 첫 장에만 보여주는 고정 배경 설명. */
#chat-screen .toema-prologue { margin: 6px 0 18px; min-height: min-content; border: 1px solid rgba(185,152,90,.4); border-radius: 18px; background: rgba(255,250,241,.96); color: #5b4337; box-shadow: 0 6px 24px #493d2e12; }
#chat-screen .toema-prologue-art { display: block; width: 100%; height: auto; aspect-ratio: 2 / 1; object-fit: cover; object-position: center 35%; border-radius: 17px 17px 0 0; border-bottom: 1px solid rgba(185,152,90,.3); background: #f2e9d8; }
#chat-screen .toema-prologue-body { padding: 22px 22px 24px; }
#chat-screen .toema-prologue h3 { margin: 0 0 16px; color: #4a2f27; font: 700 20px/1.5 var(--serif); letter-spacing: -.035em; word-break: keep-all; }
#chat-screen .toema-prologue p { margin: 0 0 14px; font: 400 15px/2 var(--serif); letter-spacing: -.01em; word-break: keep-all; overflow-wrap: anywhere; }
#chat-screen .toema-prologue p:last-of-type { margin-bottom: 0; }
#chat-screen.view-novel .toema-prologue { background: #272c35; border-color: #65583d; color: #d9d4c8; }
#chat-screen.view-novel .toema-prologue h3 { color: #efe6d4; }
#chat-screen.has-toema-prologue-gate .chat-composer,
#chat-screen.has-toema-prologue-gate .chat-suggest-zone,
#chat-screen.has-toema-prologue-gate #typing { display: none; }
#chat-screen .toema-prologue-next { display: block; margin: 22px auto 0; min-width: 120px; padding: 10px 20px; border: 1px solid #b9985a; border-radius: 10px; background: #fffaf1; color: #65483b; font: 600 14px/1.4 var(--sans); cursor: pointer; }
#chat-screen .toema-prologue-next:disabled { opacity: .5; cursor: default; }
@media (prefers-reduced-motion: reduce) { #chat-screen .bubble, #chat-screen .chat-narration, #chat-screen .chat-scene-act { animation: none; } }

.ui-page-tools:not(:has(> :not([hidden]))) { display: none; }

/* Paper conversation: distinct header, readable messages and a quiet writing tray. */
#chat-screen:not(.view-novel){--report-ink:var(--ui-ink);--report-muted:var(--ui-muted);--report-meta:#807467;--report-line:var(--ui-line);--report-surface:var(--ui-soft)}
#chat-screen .chat-topbar{grid-template-columns:36px minmax(0,1fr) auto;gap:8px;padding:12px 14px;min-height:76px}
#chat-screen .chat-back{width:36px;min-height:44px;font-size:34px;border-radius:12px}
#chat-screen .persona-tab{justify-items:start;min-width:0}
#chat-screen .persona-tab strong{letter-spacing:-.025em}
#chat-screen .persona-tab small{font-size:12px}
#chat-screen .chat-topbar .screen-actions{gap:4px;min-width:0}
#chat-screen:not(.view-novel) .chat-topbar{background:rgba(255,253,248,.98);box-shadow:0 4px 18px #55312d04}
#chat-screen:not(.view-novel) .chat-messages{gap:18px;padding:24px 2px 22px;align-content:start}
#chat-screen:not(.view-novel) .bubble{padding:13px 16px;border-radius:5px 18px 18px;font-size:15px;line-height:1.8;overflow-wrap:anywhere}
#chat-screen:not(.view-novel) .message.assistant .bubble{border-color:#e8dfd2;background:#fffdf8;box-shadow:0 2px 8px #55312d04}
#chat-screen:not(.view-novel) .message.user .bubble{border-radius:18px 5px 18px 18px;background:var(--ui-action);color:#fffdf8}
#chat-screen:not(.view-novel) .message-name{font-size:12px;color:var(--ui-muted)}
#chat-screen:not(.view-novel) .message.user .avatar{background:var(--ui-soft);color:var(--ui-action)}
#chat-screen:not(.view-novel) .chat-bubble-act{color:#776d60;line-height:1.8}
#chat-screen:not(.view-novel) .message.user .chat-bubble-act{color:#e1d0c8}
#chat-screen:not(.view-novel) .chat-act-row{border-radius:12px;padding:10px 14px;max-width:90%;line-height:1.8}
#chat-screen:not(.view-novel) .chat-composer{border-color:var(--ui-line);box-shadow:0 -6px 24px #55312d04}
#chat-screen .chat-form{align-items:flex-end;gap:8px;padding:12px 2px}
#chat-screen .chat-form textarea{border-radius:16px;padding:13px 14px;font-size:16px;line-height:1.5}
#chat-screen:not(.view-novel) .chat-form textarea{background:var(--ui-surface)}
#chat-screen:not(.view-novel) .chat-form textarea::placeholder{color:#8a7c6e}
#chat-screen:not(.view-novel) .chat-form textarea:focus{border-color:var(--ui-action);outline:2px solid #55312d20;outline-offset:2px}
#chat-screen .chat-form>button[type=submit]{border-radius:16px}
#chat-screen .chat-suggestion{min-height:40px;font-size:13px}
#chat-screen .chat-form .prologue-choice{min-height:44px;white-space:normal;max-width:100%;text-align:left;line-height:1.55}
#chat-screen:not(.view-novel) .chat-form .chat-profile-choice.selected,#chat-screen:not(.view-novel) .chat-form .chat-profile-next{background:var(--ui-action);border-color:var(--ui-action)}
#chat-screen .chat-profile-fields input,#chat-screen .chat-profile-fields select{font-size:16px}
#chat-screen :is(button,summary,a):focus-visible,.cheong-card button:focus-visible,.chat-upgrade-dialog :is(button,a):focus-visible{outline:2px solid var(--ui-gold);outline-offset:3px}
.chat-room{padding:18px 16px;border-radius:18px;border-color:var(--ui-line);background:var(--ui-surface);box-shadow:0 3px 14px #55312d04}
.chat-room-avatar{border-radius:18px}.chat-room-copy{gap:5px}.chat-room-copy strong{font-size:17px}.chat-room-arrow{color:var(--ui-gold)}
.chat-list-daily{border:1px solid var(--ui-line);border-radius:16px;color:var(--ui-muted)}
.cheong-card{padding-bottom:calc(24px + env(safe-area-inset-bottom,0px));box-shadow:0 16px 60px #302b2626}
.cheong-card .card-close,.chat-upgrade-close{display:grid;place-items:center;width:44px;height:44px;min-height:44px;padding:0}
.cheong-card .card-head{padding:20px 20px 8px}.cheong-card .card-section{padding-top:20px}.cheong-card .card-section+.card-section{margin-top:4px}
.cheong-card .card-tab{min-height:44px}.cheong-card .card-places li{padding:10px;border:1px solid var(--report-line);border-radius:14px}
.chat-upgrade-dialog{max-height:calc(100dvh - 32px);overflow-y:auto}.chat-upgrade-later{min-height:44px}.toema-reward-dialog{max-height:calc(100dvh - 32px);overflow-y:auto;background:var(--ui-surface);border-color:var(--ui-line);padding:20px}.toema-reward-dialog>button{min-height:44px;width:100%;background:var(--ui-action);color:#fffdf8;border-color:var(--ui-action)}
@media(max-width:360px){#chat-screen .chat-topbar{gap:4px;padding-inline:10px;grid-template-columns:32px minmax(0,1fr) auto}#chat-screen .persona-tab{grid-template-columns:36px minmax(0,1fr);column-gap:7px}#chat-screen .persona-avatar{width:36px;height:36px}#chat-screen .persona-tab strong{font-size:14px}#chat-screen:not(.view-novel) .bubble{padding:11px 13px;font-size:14px}.chat-room{gap:12px;padding:16px 12px}.chat-room-avatar{width:52px;height:52px;flex-basis:52px}}
@media(prefers-reduced-motion:reduce){.cheong-card,.cheong-card-overlay{animation:none}}
/* 좁은 상단바에서도 현재 친밀도 레벨을 읽을 수 있게 한다. */
#chat-screen .persona-tabs { min-width: 0; }
#chat-screen .persona-tab { min-width: 0; }
#chat-screen .persona-sub { font-weight: 600; }
@media (max-width: 600px) { #chat-screen .persona-sub i { display: none; } }

/* 엽전 칩은 눌러서 충전 팝업을 여는 단추다. 보관함 제목 줄에서는 오른쪽 끝에 둔다. */
.chat-coin-chip { cursor: pointer; }
.chat-coin-chip:focus-visible { outline: 2px solid #8b754d; outline-offset: 2px; }
.archive-screen .ui-page-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.archive-screen .ui-page-header .chat-coin-chip { flex: 0 0 auto; margin-left: auto; display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px; border: 1px solid #d8c8a9; border-radius: 999px; color: #6e5636; background: #f8f0df; font: 650 12px/1 var(--sans); white-space: nowrap; }
.archive-screen .ui-page-header .chat-coin-chip[hidden] { display: none; }
.archive-screen .ui-page-header .chat-coin-chip i { position: relative; width: 16px; height: 16px; border: 2px solid #8d6838; border-radius: 50%; background: #d9b873; }
.archive-screen .ui-page-header .chat-coin-chip i::after { content: ""; position: absolute; inset: 3px; border: 1px solid #8d6838; background: #f8f0df; }
.archive-screen .ui-page-header .chat-coin-chip b { color: #4a3a22; font-size: 14px; font-weight: 800; }

/* 월화문답 제목 줄: 제목은 왼쪽, 캐릭터 생성(운영자)과 엽전은 오른쪽 끝에 붙여 엽전이 최우측에 온다. */
#chat-list-screen > .ui-page-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
#chat-list-screen > .ui-page-header .chat-list-heading { flex-wrap: nowrap; margin: 0 0 0 auto; }
#chat-list-screen > .ui-page-header .chat-list-heading .chat-coin-chip { margin-left: 0; }

/* 글자 재생 차례가 오기 전의 말풍선은 빈 틀로 보이지 않게 한다. */
#chat-screen .is-pending { display: none; }

/* 툇마루에서 연 캐릭터카드: 위쪽 탭(인트로 / 주월). 인트로는 첫 화면의 인트로 카드와 같다. */
.cheong-card .card-close { top: 15px; right: 14px; width: 30px; height: 30px; min-height: 30px; font-size: 20px; }
.cheong-card .card-tabs-top { margin: 14px 52px 0 16px; padding: 4px; }
.cheong-card .card-tabs-top .card-tab { min-height: 32px; padding: 6px; font-size: 13px; }
.cheong-card .card-intro-panel { padding: 16px 16px 22px; }
.cheong-card .card-intro-panel .toema-prologue { margin: 0; }
.cheong-card .card-character[hidden], .cheong-card .card-intro-panel[hidden] { display: none; }
/* 주월 탭의 사진도 인트로 카드와 같은 좌우 여백·둥근 모서리로 맞춘다. */
.cheong-card .card-character .card-hero { margin: 16px 16px 0; border-radius: 16px; overflow: hidden; }
.cheong-card .card-character .card-head { padding-top: 16px; }

/* 본채 주월: 얼굴이 작게 읽히던 것을 키운다. 동그라미를 키우고, 그림도 얼굴 쪽으로 더 당겨 담는다. */
.avatar.is-cheong .avatar-image { object-fit: cover; object-position: 50% 50%; }
#chat-screen .message .avatar.is-cheong { width: 46px; height: 46px; flex-basis: 46px; }
body.is-chat #chat-screen .persona-avatar.is-cheong { width: 42px; height: 42px; }
body.is-chat #chat-screen .persona-tab:has(.is-cheong),
body.is-chat #chat-screen .persona-tab.active:has(.is-cheong) { grid-template-columns: 42px 1fr; }
#chat-screen .chat-room-avatar.is-cheong, .chat-room-avatar.is-cheong { width: 72px; height: 72px; flex-basis: 72px; }

/* 명식이 없을 때 뜨는 안내: 주월 얼굴, 짧은 설명, 세 단계, 가운데 정렬된 단추 */

/* 첫 질문 뒤 답이 오기 전까지 펼치는 만세력 카드. 기둥이 차례로 떠오르고 일주가 은은하게 숨 쉰다. */
#chat-screen .chat-mansae { margin: 6px 0 14px; padding: 14px 12px 12px; border: 1px solid #e8dfcf; border-radius: 16px; background: #fffdf8; box-shadow: 0 4px 16px rgba(73, 61, 46, .06); animation: mansae-in .5s ease both; }
#chat-screen .chat-mansae-title { margin: 0 0 10px; color: #6a3028; font: 700 13px/1.4 var(--sans); text-align: center; letter-spacing: .02em; }
#chat-screen .chat-mansae-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
#chat-screen .chat-mansae-pillar { display: grid; justify-items: center; align-content: start; gap: 4px; padding: 8px 2px 10px; border: 1px solid #ece3d3; border-radius: 12px; background: #fff; opacity: 0; transform: translateY(8px); animation: mansae-pillar .5s ease forwards; animation-delay: calc(.15s + var(--i, 0) * .13s); }
#chat-screen .chat-mansae-pillar > small { color: #8b806f; font: 600 11px/1.3 var(--sans); }
#chat-screen .chat-mansae-pillar.is-day { border: 2px solid #b8365a; background: #fdf2f5; }
#chat-screen .chat-mansae-pillar.is-day > small { color: #b8365a; }
#chat-screen .chat-mansae-pillar.is-day { animation: mansae-pillar .5s ease forwards, mansae-breathe 2.4s ease-in-out 1s infinite; animation-delay: calc(.15s + var(--i, 0) * .13s), 1.2s; }
#chat-screen .chat-mansae-pillar.is-empty { background: #f6f2ea; border-style: dashed; }
#chat-screen .chat-mansae-char { display: grid; justify-items: center; gap: 1px; width: 100%; }
#chat-screen .chat-mansae-char em { min-height: 14px; color: #8b806f; font: 500 10.5px/1.3 var(--sans); font-style: normal; letter-spacing: -.02em; }
#chat-screen .chat-mansae-char em.is-stem { color: #6a3028; }
#chat-screen .chat-mansae-char b { font: 700 28px/1.15 var(--serif); }
#chat-screen .chat-mansae-char i { color: #8b806f; font: 500 11px/1.2 var(--sans); font-style: normal; }
#chat-screen .chat-mansae-char + .chat-mansae-char { margin-top: 2px; padding-top: 5px; border-top: 1px dashed #e6dccb; }
#chat-screen .chat-mansae-none { color: #8b806f; font: 500 11px/1.4 var(--sans); }
#chat-screen .chat-mansae b.wood { color: #4f7a52; } #chat-screen .chat-mansae b.fire { color: #b5483a; } #chat-screen .chat-mansae b.earth { color: #9a7a3f; } #chat-screen .chat-mansae b.metal { color: #6f7680; } #chat-screen .chat-mansae b.water { color: #3f6f99; }
#chat-screen .chat-mansae-note { margin: 10px 0 0; color: #8b806f; font: 500 12px/1.4 var(--sans); text-align: center; animation: mansae-note 1.6s ease-in-out infinite; }
@keyframes mansae-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes mansae-pillar { to { opacity: 1; transform: none; } }
@keyframes mansae-breathe { 0%, 100% { box-shadow: 0 0 0 0 rgba(184, 54, 90, .0); } 50% { box-shadow: 0 0 0 5px rgba(184, 54, 90, .12); } }
@keyframes mansae-note { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
@media (max-width: 360px) { #chat-screen .chat-mansae-char b { font-size: 24px; } }
@media (prefers-reduced-motion: reduce) { #chat-screen .chat-mansae, #chat-screen .chat-mansae-pillar, #chat-screen .chat-mansae-note { animation: none; opacity: 1; transform: none; } }
#chat-screen.view-novel .chat-mansae { background: #272c35; border-color: #3d4350; }
#chat-screen.view-novel .chat-mansae-pillar { background: #2f3541; border-color: #444b59; }
#chat-screen.view-novel .chat-mansae-title, #chat-screen.view-novel .chat-mansae-char em.is-stem { color: #efe6d4; }

/* 상단바 이름 옆 방 표지: 본채는 진한 갈색, 사랑방은 딥 로즈, 툇마루는 따뜻한 베이지로 한눈에 구분한다. */
#chat-screen .persona-room { display: inline-block; margin-left: 6px; padding: 2px 7px; border-radius: 999px; font: 700 10.5px/1.35 var(--sans); letter-spacing: 0; vertical-align: 2px; white-space: nowrap; }
#chat-screen .persona-room.is-cheong { background: #55312d; color: #fff8e9; }
#chat-screen .persona-room.is-sarang { background: #fdf2f5; color: #b8365a; box-shadow: inset 0 0 0 1px #f0c9d4; }
#chat-screen .persona-room.is-toema { background: #f8f1e6; color: #8c6e53; box-shadow: inset 0 0 0 1px #e6d8bf; }
#chat-screen.view-novel .persona-room.is-cheong { background: #e8dcc6; color: #2b2118; }
#chat-screen.view-novel .persona-room.is-sarang { background: #3a2a33; color: #f0a9bd; box-shadow: inset 0 0 0 1px #5b3a47; }
#chat-screen.view-novel .persona-room.is-toema { background: #3a352b; color: #d8c49a; box-shadow: inset 0 0 0 1px #57503f; }
@media (max-width: 360px) {
  /* 좁은 화면에서는 방 표지를 이름 아래 줄로 내려 오른쪽 버튼과 겹치지 않게 한다. */
  #chat-screen .persona-tab strong { white-space: normal; }
  #chat-screen .persona-room { display: block; width: fit-content; margin: 1px 0 0; padding: 1px 6px; font-size: 10px; vertical-align: baseline; }
}
@media (max-width: 340px) {
  #chat-screen .persona-room { padding: 1px 5px; font-size: 9.5px; }
  #chat-screen .persona-avatar { width: 36px; height: 36px; }
}

/* 주월 말풍선은 한 묶음 안에서 모양이 섞이지 않게 모두 같은 둥근 모서리로 둔다(첫 말풍선만 좌상단이 각지던 규칙을 없앤다). */
#chat-screen:not(.view-novel) .message.assistant .bubble,
#chat-screen:not(.view-novel) .message.assistant .message-body .bubble + .bubble { border-radius: 18px; }

/* 탭 머리글(만세력·소원빌기·상담소·보관함): 제목 바로 아래 줄에 설명을 둔다. */
.ui-page-titles { display: grid; gap: 2px; min-width: 0; margin-right: auto; }
.ui-page-titles .ui-page-title { margin: 0; }
.ui-page-titles .wishes-checkin-hint { display: block; color: var(--ui-muted); font: 500 13px/1.3 var(--sans); letter-spacing: -.02em; }
.wishes-page-header { display: block; }

#chat-screen .chat-meta { flex: 0 0 auto; align-self: flex-end; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
#chat-screen .chat-meta .chat-time { align-self: auto; }
#chat-screen .chat-copy { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: #a39d92; cursor: pointer; }
#chat-screen .chat-copy:hover, #chat-screen .chat-copy:focus-visible { color: #4a4335; background: rgba(0, 0, 0, .06); }
#chat-screen > .chat-copy, #chat-screen .message-body > .chat-copy { align-self: flex-start; margin-top: 2px; }
#chat-screen.view-novel .chat-meta { align-items: flex-start; flex-direction: row; gap: 8px; align-self: flex-start; }
#chat-screen.view-novel .chat-copy { color: #7d838e; }

/* 사랑방 카드 얼굴: 본채와 다른 그림(벚꽃). 가로로 긴 그림이라 가운데 정사각을 쓴다. */
.chat-room-sarang .chat-room-avatar .avatar-image{object-fit:cover;object-position:50% 50%}
