/* AI 캐릭터 챗: 대화 상자(static/v2/js/chat.js)와 작가 스튜디오 'AI 캐릭터' 화면. 공통 조각은 v2.css·studio.css */

/* ---------- 대화 상자 ---------- */
.chat { display: flex; flex-direction: column; min-height: 0; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-l); overflow: hidden; }
.chat-log { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 16px; scroll-behavior: smooth; }
.chat-situation { align-self: center; max-width: 92%; padding: 8px 12px; border-radius: var(--radius); background: var(--bg-elev); color: var(--text-2); font-size: 13px; line-height: 1.6; text-align: center; }
.chat-row { display: flex; gap: 8px; align-items: flex-start; }
.chat-row.is-user { justify-content: flex-end; }
.chat-col { display: flex; flex-direction: column; gap: 4px; min-width: 0; max-width: 85%; }
.chat-avatar { flex: none; width: 34px; height: 34px; border-radius: 999px; object-fit: cover; background: var(--bg-elev-2); }
.chat-avatar.is-empty { display: grid; place-items: center; font-size: 14px; font-weight: 800; color: var(--brand); background: var(--brand-weak); }
.chat-name { font-size: 12px; font-weight: 700; color: var(--text-2); }
.chat-msg { padding: 10px 14px; border-radius: 18px; font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; }
.chat-msg.is-user { max-width: 85%; background: var(--brand); color: var(--brand-ink); border-bottom-right-radius: 6px; }
.chat-msg.is-char { background: var(--bg-elev-2); color: var(--text); border-top-left-radius: 6px; }
.chat-act { font-style: italic; color: var(--text-3); }
.chat-msg.is-user .chat-act { color: rgba(255, 255, 255, 0.8); }
.chat-tool { align-self: flex-start; padding: 2px 4px; font-size: 12px; font-weight: 600; color: var(--text-3); }
.chat-tool:hover { color: var(--brand); }
.chat-notice { align-self: center; max-width: 92%; padding: 6px 12px; border-radius: 999px; background: var(--bg-elev-2); color: var(--text-2); font-size: 12px; text-align: center; }
.chat-typing { display: inline-flex; gap: 4px; align-items: center; height: 40px; }
.chat-typing i { width: 6px; height: 6px; border-radius: 999px; background: var(--text-3); animation: chat-dot 1s infinite ease-in-out; }
.chat-typing i:nth-child(2) { animation-delay: .15s; }
.chat-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes chat-dot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .chat-typing i { animation: none; opacity: .6; } }
.chat-input { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px; border-top: 1px solid var(--line); background: var(--bg-elev); }
.chat-input textarea { flex: 1; min-height: 40px; max-height: 132px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 20px; background: var(--bg); color: var(--text); font: inherit; font-size: 14px; line-height: 1.5; resize: none; }
.chat-input textarea:focus { outline: none; border-color: var(--brand); }
.chat-send { flex: none; width: 40px; height: 40px; border-radius: 999px; display: grid; place-items: center; background: var(--brand); color: var(--brand-ink); }
.chat-send:disabled { opacity: .5; }
.chat-send .icon { width: 18px; height: 18px; }
.chat-foot { padding: 0 14px 10px; font-size: 12px; color: var(--text-3); background: var(--bg-elev); }
.chat-foot:empty { display: none; }

/* ---------- 스튜디오: 캐릭터 목록 ---------- */
.char-cover { aspect-ratio: 1 / 1; }
.char-status { position: absolute; top: 10px; left: 10px; }
.char-status.is-public { background: #12a150; }
.char-status.is-pending { background: #d98b00; }
.char-status.is-rejected, .char-status.is-hidden { background: #c63d3d; }
.char-work { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.char-note { font-size: 12px; line-height: 1.5; color: #c63d3d; }
.char-actions { grid-template-columns: 1fr; }
.char-tips { margin-top: 24px; }
.char-tips ul { margin: 0; padding: 14px 18px 16px 34px; display: grid; gap: 6px; font-size: 13px; line-height: 1.6; color: var(--text-2); }

/* ---------- 스튜디오: 캐릭터 만들기 ---------- */
.char-alert { margin-bottom: 16px; padding: 12px 16px; border-radius: var(--radius); background: var(--bg-elev); border: 1px solid var(--line); font-size: 14px; line-height: 1.6; }
.char-alert.is-pending { border-color: #d98b00; }
.char-alert.is-public { border-color: #12a150; }
.char-alert.is-rejected, .char-alert.is-hidden { border-color: #c63d3d; }
.char-image-row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.char-image { width: 96px; height: 96px; border-radius: 999px; object-fit: cover; background: var(--bg-elev-2); flex: none; }
.char-image.is-empty { display: grid; place-items: center; color: var(--text-3); font-size: 28px; font-weight: 800; }
.char-image-tools { display: flex; flex-wrap: wrap; gap: 8px; }
.char-example { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); }
.char-example + .char-example { margin-top: 10px; }
.char-example-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 700; color: var(--text-2); }
.sfield .is-error, .sfield .is-error:focus { border-color: #c63d3d; }
.char-draft { display: grid; gap: 10px; padding: 14px; border: 1px dashed var(--brand); border-radius: var(--radius); background: var(--brand-weak); }
.char-draft-head { display: grid; gap: 4px; }
.char-draft-head strong { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.char-draft-head strong .icon { width: 16px; height: 16px; color: var(--brand); }
.char-draft-head span { font-size: 12px; line-height: 1.5; color: var(--text-2); }
.char-draft-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; color: var(--text-3); }
.char-draft-foot .btn { flex: none; }
.char-draft-undo { font-size: 12px; color: var(--text-2); }
.char-draft-undo button { color: var(--brand); font-weight: 700; text-decoration: underline; }
.field-error { margin-top: 4px; font-size: 12px; color: #c63d3d; }
.char-preview-card { display: grid; gap: 10px; }
.char-preview-head { display: flex; gap: 12px; align-items: center; }
.char-preview-head .char-image { width: 56px; height: 56px; font-size: 20px; }
.char-preview-head strong { display: block; font-size: 16px; }
.char-preview-head span { font-size: 12px; color: var(--text-3); }
.char-preview-intro { font-size: 13px; line-height: 1.6; color: var(--text-2); }
.char-preview-chat { height: 520px; margin-top: 4px; }
.char-preview-tools { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; color: var(--text-3); }
.char-dialog { display: block; }
.char-dialog .studio-modal-card { max-width: 440px; }
.char-dialog p { margin: 10px 0 18px; font-size: 14px; line-height: 1.6; color: var(--text-2); }
.char-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.char-toast { position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%); z-index: 120; padding: 10px 18px; border-radius: var(--radius); background: var(--text); color: var(--bg); font-size: 14px; box-shadow: var(--shadow); max-width: calc(100% - 32px); }
@media (max-width: 960px) {
  .char-preview-chat { height: 440px; }
}

/* ---------- 대화 상자: 이전 대화·고급 표시 ---------- */
.chat-older { align-self: center; padding: 6px 14px; border-radius: 999px; background: var(--bg-elev-2); color: var(--text-2); font-size: 12px; font-weight: 600; }
.chat-older:hover { color: var(--text); }
.chat-tag { display: inline-flex; align-items: center; height: 16px; padding: 0 5px; margin-left: 4px; border-radius: 4px; background: var(--brand-weak); color: var(--brand); font-size: 10px; font-weight: 800; vertical-align: 1px; }

/* ---------- 독자: 캐릭터 둘러보기 ---------- */
.cc-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.cc-head h1 { font-size: 26px; font-weight: 800; margin: 0; }
.cc-head p { margin-top: 6px; font-size: 14px; color: var(--text-2); line-height: 1.6; }
.cc-sorts { display: flex; gap: 6px; }
.cc-sorts a { height: 34px; display: inline-flex; align-items: center; padding: 0 14px; border-radius: 999px; background: var(--bg-elev-2); color: var(--text-2); font-size: 13px; font-weight: 600; }
.cc-sorts a[aria-current="page"] { background: var(--text); color: var(--bg); }
.cc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 18px 14px; }
/* 캐릭터 카드(.cc-tile)는 메인·검색·작품 상세에서도 쓰므로 v2.css 에 있다 */

/* ---------- 독자: 캐릭터 소개 ---------- */
.cc-preview { margin-bottom: 16px; padding: 10px 14px; border-radius: var(--radius); background: var(--brand-weak); color: var(--brand); font-size: 13px; font-weight: 600; }
.cc-hero { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; align-items: start; }
.cc-hero-img { aspect-ratio: 1 / 1; border-radius: var(--radius-l); overflow: hidden; background: var(--bg-elev-2); }
.cc-hero-img img { width: 100%; height: 100%; object-fit: cover; }
.cc-hero h1 { font-size: 28px; font-weight: 800; margin: 0; }
.cc-hero-work { display: inline-block; margin-top: 6px; font-size: 14px; color: var(--text-2); }
.cc-hero-work:hover { color: var(--brand); }
.cc-hero-intro { margin-top: 12px; font-size: 15px; line-height: 1.7; color: var(--text); white-space: pre-line; }
.cc-hero-stats { display: flex; gap: 14px; margin-top: 12px; font-size: 13px; color: var(--text-3); }
.cc-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.cc-price { margin-top: 10px; font-size: 12px; color: var(--text-3); line-height: 1.6; }
.cc-start { margin-top: 28px; display: grid; gap: 12px; max-width: 720px; }
.cc-start h2 { font-size: 16px; font-weight: 800; margin: 0; }
.cc-start .chat-situation { align-self: flex-start; text-align: left; max-width: 100%; }
.cc-greeting { display: flex; gap: 8px; align-items: flex-start; }
.cc-greeting .chat-msg { max-width: 600px; }

/* ---------- 독자: 내 대화 ---------- */
.chat-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-l); overflow: hidden; background: var(--bg-elev); }
.chat-list li + li { border-top: 1px solid var(--line); }
.chat-item { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.chat-item:hover { background: var(--bg-hover); }
.chat-item-link { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.chat-item .chat-avatar { width: 48px; height: 48px; font-size: 18px; }
.chat-item-body { display: block; flex: 1; min-width: 0; }
.chat-item-name { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 15px; }
.chat-item-last { display: block; margin-top: 2px; font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item-time { flex: none; font-size: 12px; color: var(--text-3); }
.chat-item-off { font-size: 11px; color: var(--text-3); font-weight: 600; }

/* ---------- 독자: 대화 화면 ---------- */
.page.chat-main { padding-bottom: 16px; }
.chat-main + .footer { display: none; }   /* 대화 화면은 화면 높이에 맞추므로 사이트 하단 정보를 숨긴다 (입력할 때 화면이 밀리지 않게) */
.chat-page { display: flex; flex-direction: column; gap: 10px; height: calc(100dvh - var(--topbar-h) - 24px); min-height: 480px; max-width: 860px; margin: 0 auto; }
.chat-head { display: flex; align-items: center; gap: 10px; }
.chat-head .chat-avatar { width: 40px; height: 40px; }
.chat-head-name { flex: 1; min-width: 0; }
.chat-head-name a { display: block; font-size: 16px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head-name span { display: block; font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head-tools { display: flex; gap: 4px; }
.mode-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.mode-seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--bg-elev-2); }
.mode-seg button { height: 32px; padding: 0 14px; border-radius: 999px; font-size: 13px; font-weight: 700; color: var(--text-2); }
.mode-seg button[aria-pressed="true"] { background: var(--bg); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.mode-seg button.is-premium[aria-pressed="true"] { color: var(--brand); }
.mode-info { font-size: 12px; color: var(--text-3); }
.mode-info strong { color: var(--text-2); }
.chat-page .chat { flex: 1; min-height: 0; }
.chat-off { padding: 10px 14px; border-radius: var(--radius); background: var(--bg-elev-2); color: var(--text-2); font-size: 13px; }

/* ---------- 독자 화면 확인 창 (브라우저 기본 confirm 대신) ---------- */
.cc-modal { position: fixed; inset: 0; z-index: 130; display: flex; align-items: flex-start; justify-content: center; padding: 12vh 16px 24px; background: var(--overlay); }
.cc-modal[hidden] { display: none; }
.cc-dialog { width: 100%; max-width: 420px; padding: 20px 22px; border-radius: var(--radius-l); background: var(--bg-elev); border: 1px solid var(--line); box-shadow: var(--shadow); }
.cc-dialog h2 { font-size: 18px; font-weight: 800; margin: 0 0 8px; }
.cc-dialog p { font-size: 14px; line-height: 1.6; color: var(--text-2); }
.cc-reasons { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.cc-reasons label { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 999px; background: var(--bg-elev-2); font-size: 13px; cursor: pointer; }
.cc-reasons input { accent-color: var(--brand); }
.cc-dialog textarea { width: 100%; min-height: 72px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); color: var(--text); font: inherit; font-size: 14px; resize: vertical; }
.cc-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.cc-toast { position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 140; padding: 10px 18px; border-radius: var(--radius); background: var(--text); color: var(--bg); font-size: 14px; box-shadow: var(--shadow); max-width: calc(100% - 32px); }
.cc-toast[hidden] { display: none; }

@media (max-width: 760px) {
  .cc-hero { grid-template-columns: 1fr; gap: 16px; }
  .cc-hero-img { max-width: 200px; }
  .cc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 10px; }
  .page.chat-main { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  .chat-page { height: calc(100dvh - var(--topbar-h) - 76px - env(safe-area-inset-bottom)); min-height: 400px; }
}

/* AI 캐릭터 서비스 동의 창 (v2/_chat_consent.html, 약관 동의 하나)·동의 철회 (내 대화)·스튜디오 미리 대화 안내 */
.cc-consent { max-width: 460px; max-height: 80vh; overflow-y: auto; }
.cc-consent-points { margin: 4px 0 14px; padding-left: 18px; font-size: 13px; line-height: 1.6; color: var(--text-2); }
.cc-check { display: flex; align-items: center; gap: 8px; min-height: 36px; font-size: 14px; cursor: pointer; }
.cc-check input { width: 18px; height: 18px; flex: none; accent-color: var(--brand); }
.cc-check-all { margin-bottom: 4px; padding: 0 12px; border-radius: var(--radius); background: var(--bg-elev-2); font-weight: 700; }
.cc-check-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 12px; }
.cc-more { flex: none; padding: 0; border: 0; background: none; color: var(--text-3); font: inherit; font-size: 13px; text-decoration: underline; cursor: pointer; }
.cc-dialog .cc-consent-note { margin-top: 10px; font-size: 12px; color: var(--text-3); }
.cc-dialog .cc-consent-note a { text-decoration: underline; }
.cc-dialog .cc-consent-error { margin-top: 8px; font-size: 13px; color: #ef4444; }
.cc-withdraw { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 24px; padding: 14px 16px; border-radius: var(--radius-l); background: var(--bg-elev); border: 1px solid var(--line); font-size: 13px; line-height: 1.6; color: var(--text-3); }
.char-consent { padding: 16px; border-radius: var(--radius); background: var(--bg-elev-2); font-size: 13px; line-height: 1.6; color: var(--text-2); }
.char-consent p { margin-bottom: 10px; }
@media (max-width: 600px) {
  .cc-withdraw { flex-direction: column; align-items: flex-start; }
}

/* 스튜디오 캐릭터 수익 (v2/studio_character_earnings.html) */
.char-head-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.char-earn-note { font-size: 12px; color: var(--text-3); }
.char-earn-kind { display: block; margin-top: 2px; font-size: 12px; font-weight: 400; color: var(--text-3); }
.char-earn-empty { margin: 0; padding: 20px 18px; font-size: 14px; color: var(--text-2); }
.char-earn-table td:first-child { min-width: 9.5em; }   /* 휴대폰에서 이름이 한두 글자씩 꺾이지 않게, 표는 옆으로 밀린다 */
.studio-kicker a { color: inherit; text-decoration: none; }
