/* 1:1 캐릭터 챗 상단 슬림 헤더 & 팝오버 */
.chat-header-wrap {
  position: relative;
  flex-shrink: 0;
  z-index: 15;
}

.private-chat-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  min-height: 54px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(15, 17, 25, 0.65);
}

.chat-entity-trigger {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 4px 8px 4px 4px;
  color: var(--text-main);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  min-width: 0;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.chat-entity-trigger:hover,
.chat-entity-trigger.open {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border-subtle);
}

.chat-title-stack {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-title-line {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.chat-title-line strong {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lock-hint {
  color: var(--text-dim);
  display: inline-flex;
}

.chevron-wrap {
  color: var(--text-muted);
  display: inline-flex;
  transition: transform 0.18s ease;
}

.chat-entity-trigger.open .chevron-wrap {
  transform: rotate(180deg);
}

.chat-sub-line {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dot-sep {
  opacity: 0.45;
  margin: 0 2px;
}

.travel-inline {
  color: var(--accent-indigo-light);
}

.chat-topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.action-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip-encounter {
  background: rgba(251, 113, 133, 0.13);
  border: 1px solid rgba(251, 113, 133, 0.32);
  color: var(--accent-crimson);
}

.chip-encounter:hover,
.chip-encounter.active {
  background: rgba(251, 113, 133, 0.24);
  border-color: var(--accent-crimson);
}

/* 플로팅 전환 팝오버 & 조우 팝오버 */
.chat-floating-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 10px;
  right: 10px;
  max-width: 380px;
  background: rgba(20, 23, 34, 0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 10px;
  box-shadow: var(--shadow-popover);
  max-height: 310px;
  overflow-y: auto;
  z-index: 25;
}

.encounter-popover {
  left: auto;
  right: 10px;
  width: min(320px, calc(100% - 20px));
}

.popover-caption {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  padding: 2px 6px 8px;
}

.switcher-list,
.encounter-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.switcher-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-main);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.14s ease;
}

.switcher-item:hover {
  background: rgba(255, 255, 255, 0.055);
}

.switcher-item.active {
  background: rgba(99, 102, 241, 0.14);
  border-color: rgba(99, 102, 241, 0.32);
}

.switcher-item-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.switcher-item-body strong {
  font-size: 13px;
  font-weight: 600;
}

.switcher-item-body span {
  font-size: 11px;
  color: var(--text-muted);
}

.encounter-action-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(251, 113, 133, 0.28);
  background: rgba(251, 113, 133, 0.1);
  color: var(--text-main);
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.encounter-action-btn:hover:not(:disabled) {
  background: rgba(251, 113, 133, 0.2);
}

.cost-tag {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-crimson);
  background: rgba(9, 10, 15, 0.45);
  padding: 2px 7px;
  border-radius: var(--radius-pill);
}

/* 접이식 캐릭터 상세 드로어 (기본 숨김 — 플로팅 오버레이로 채팅 영역 압박 방지) */
.chat-info-drawer {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: min(62vh, 430px);
  overflow-y: auto;
  z-index: 26;
  padding: 12px 14px 14px;
  border-bottom: 1px solid var(--border-strong);
  background: rgba(16, 19, 29, 0.98);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-popover);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.info-drawer-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.info-drawer-top-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.role-tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-indigo-light);
  background: rgba(99, 102, 241, 0.14);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
}

.private-inline-note {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
}

.info-role-text {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
}

.info-state-text {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
}

.info-affinity-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 2px;
}

.aff-chip {
  background: rgba(9, 10, 15, 0.45);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  padding: 5px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  color: var(--text-muted);
}

.info-drawer-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 2px;
}

/* 대화 스트림 */
.chat-messages-scroll {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.chat-empty-state {
  margin: auto;
  max-width: 280px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 24px 12px;
}

.chat-empty-state strong {
  font-size: 15px;
  margin-top: 4px;
}

.chat-empty-state p {
  font-size: 12px;
  color: var(--text-muted);
}

.empty-hint {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 6px;
  line-height: 1.5;
}

.msg-row {
  display: flex;
  max-width: 82%;
  gap: 9px;
}

.msg-row.mine {
  align-self: flex-end;
  flex-direction: column;
  align-items: flex-end;
}

.msg-row.theirs {
  align-self: flex-start;
  align-items: flex-start;
}

.msg-theirs-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  min-width: 0;
}

.msg-row.system {
  align-self: center;
  max-width: 92%;
  width: 100%;
  justify-content: center;
}

.msg-bubble {
  padding: 10px 14px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.msg-text {
  white-space: pre-wrap;
}

.msg-row.mine .msg-bubble {
  background: linear-gradient(135deg, #5b5ef4, #6d6af8);
  color: #ffffff;
  border-radius: 18px 18px 4px 18px;
  box-shadow: 0 4px 14px rgba(91, 94, 244, 0.24);
}

.msg-row.theirs .msg-bubble {
  background: #191d29;
  border: 1px solid rgba(255, 255, 255, 0.075);
  color: var(--text-main);
  border-radius: 4px 18px 18px 18px;
}

.bubble-dice-row {
  margin-bottom: 6px;
}

/* 접이식 시스템/조우 요약 카드 (화면을 가득 채우던 주황색 박스 대체) */
.system-event-card {
  background: rgba(255, 255, 255, 0.032);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 540px;
}

.system-event-card.is-clamped .system-event-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.system-expand-btn {
  align-self: flex-end;
  background: none;
  border: none;
  color: var(--accent-indigo-light);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.msg-narration {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
  padding: 0 4px;
}

.rag-pill {
  display: inline-flex;
  align-items: center;
  font-size: 10.5px;
  color: var(--text-dim);
  padding: 0 4px;
}

/* 모던 플로팅 필 컴포저 (하단 입력창) */
.composer {
  border-top: 1px solid var(--border-subtle);
  padding: 8px 12px 10px;
  background: rgba(12, 14, 21, 0.82);
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex-shrink: 0;
}

.composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.segmented-control {
  display: inline-flex;
  padding: 2px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--border-subtle);
}

.seg-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.seg-btn em.seg-cost {
  font-style: normal;
  font-size: 10.5px;
  opacity: 0.72;
}

.seg-btn.active {
  background: var(--accent-indigo);
  color: #fff;
}

.seg-btn.seg-btn-gold.active {
  background: linear-gradient(135deg, #d8a43a, #f3c969);
  color: #15120a;
}

.composer-faith-hint {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.composer-faith-hint strong {
  color: var(--text-muted);
  font-weight: 600;
}

.composer-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.oracle-options-strip {
  display: grid;
  grid-template-columns: 144px minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 6px;
}

.pill-select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.composer-pill {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: rgba(255, 255, 255, 0.048);
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  padding: 5px 6px 5px 14px;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.composer-pill:focus-within {
  border-color: var(--accent-indigo-light);
  background: rgba(255, 255, 255, 0.068);
}

.composer-pill.pill-oracle:focus-within {
  border-color: var(--accent-gold);
}

.composer-pill textarea {
  flex: 1;
  border: none;
  background: transparent;
  padding: 6px 0;
  resize: none;
  height: 32px;
  min-height: 32px;
  max-height: 112px;
  line-height: 20px;
  font-size: 13.5px;
  color: var(--text-main);
  scrollbar-width: none;
}

.composer-pill textarea::-webkit-scrollbar {
  display: none;
}

.composer-pill textarea::placeholder {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.composer-pill textarea:focus {
  outline: none;
  border: none;
  background: transparent;
}

.send-circle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--accent-indigo);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.14s ease, background 0.14s ease;
}

.send-circle:hover:not(:disabled) {
  background: var(--accent-indigo-light);
  transform: scale(1.04);
}

.send-circle.send-gold {
  background: linear-gradient(135deg, #d8a43a, #f3c969);
  color: #15120a;
}

.send-circle:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.sending-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
