:root {
  --floating-bg: rgba(248, 241, 222, 0.96);
  --ink: #2a1f14;
  --ink-soft: #5a4432;
  --ink-muted: #8a7358;
  --accent: #a0422b;
  --sent: #6a4a28;
  --reply-bg: rgba(42, 31, 20, 0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  background: #0a0706;
  color: #eee;
  font-family: "Noto Serif KR", "Nanum Myeongjo", serif;
  overflow: hidden;
}

/* stage = 채팅창 + 방 이미지의 flex 컨테이너. 좌우 여백·중간 여백 여기서 제어 */
.stage {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 2.5vw, 40px);             /* 중간 여백 */
  padding: 0 clamp(32px, 5vw, 80px);         /* 좌우 여백 (중간의 약 2배) */
  background: radial-gradient(ellipse at 58% 50%, #1a1008 0%, #0a0604 78%);
  z-index: 1;
}

/* 방: 세로 3:4, 크게 */
.room {
  position: relative;
  flex: 0 1 auto;
  aspect-ratio: 3 / 4;
  height: min(92vh, calc(65vw * 4 / 3));
  max-width: 65vw;
  border-radius: 4px;
  overflow: hidden;
  background:
    linear-gradient(180deg, #1a0e06 0%, #2a1c10 40%, #3a2817 100%);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
}
.room-inside {
  position: absolute;
  inset: 0;
}
.room-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
}

/* 방 안에 통짜 이미지 한 장 (assets/socrates-room.png) */
.room-image {
  position: absolute;
  inset: 0;
  background-image: url('./assets/socrates-room.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-color: #060402;
}

/* 좌측 floating 창 — 이제 stage flex item */
.thought-window {
  flex: 0 0 min(360px, 32vw);
  height: 78vh;
  background: var(--floating-bg);
  color: var(--ink);
  border-radius: 6px;
  box-shadow:
    0 14px 44px rgba(0, 0, 0, 0.7),
    0 0 0 1px rgba(80, 60, 40, 0.3),
    inset 0 0 0 1px rgba(255, 255, 255, 0.5);
  display: flex;
  flex-direction: column;
  z-index: 5;
  backdrop-filter: blur(2px);
}

.tw-header {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(160, 66, 43, 0.08);
  border-bottom: 1px solid rgba(80, 60, 40, 0.22);
  font-size: 13px;
  color: var(--ink-soft);
  letter-spacing: 0.3px;
}
.tw-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: #b04025;
  box-shadow: 0 0 10px rgba(176, 64, 37, 0.7);
  animation: pulse 1.8s infinite ease-in-out;
}
@keyframes pulse {
  0%, 100% { opacity: 0.45; transform: scale(1); }
  50%      { opacity: 1;    transform: scale(1.18); }
}
.tw-title { font-weight: 600; font-family: "Noto Serif KR", serif; }

.tw-body {
  padding: 18px 20px 14px;
  overflow-y: auto;
  flex: 1;
  font-size: 15px;
  line-height: 1.7;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
/* 첫 엔트리에 margin-top: auto → 엔트리들이 하단으로 밀려붙음 */
.tw-body > .tw-entry:first-child { margin-top: auto; }
.tw-body::-webkit-scrollbar { width: 6px; }
.tw-body::-webkit-scrollbar-thumb { background: rgba(80, 60, 40, 0.28); border-radius: 3px; }

/* 카톡식 1:1 말풍선 */
.tw-entry {
  display: flex;
  flex-direction: column;
  margin-bottom: 12px;
  animation: bubble-in 0.42s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.tw-entry.sent  { align-items: flex-end; }
.tw-entry.reply { align-items: flex-start; }
.tw-entry.inner { align-items: center; }

.speaker {
  font-size: 10.5px;
  letter-spacing: 1px;
  color: var(--ink-muted);
  font-family: system-ui, "Noto Sans KR", sans-serif;
  margin: 0 6px 4px;
  opacity: 0.85;
}

.bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.6;
  word-break: keep-all;
  overflow-wrap: break-word;
  font-family: system-ui, "Noto Sans KR", sans-serif;
}
.tw-entry.sent .bubble {
  background: #ecd082;
  color: #2a1f10;
  border-top-right-radius: 4px;
  box-shadow: 0 1px 2px rgba(120, 90, 30, 0.22);
}
.tw-entry.reply .bubble {
  background: #ffffff;
  color: #2a1f14;
  border: 1px solid rgba(80, 60, 40, 0.15);
  border-top-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* 속마음 = 구름형 생각풍선 (오른쪽 정렬, 우측 아래로 방울 꼬리) */
.tw-entry.inner {
  margin-top: 8px;
  margin-bottom: 22px;
  align-items: flex-end;
}
.tw-entry.inner .bubble {
  background: rgba(255, 248, 230, 0.94);
  color: #3a2a1a;
  font-style: italic;
  font-family: "Nanum Myeongjo", "Noto Serif KR", serif;
  font-size: 14.5px;
  line-height: 1.62;
  max-width: 86%;
  padding: 13px 18px;
  text-align: left;
  border-radius: 28px 32px 26px 30px / 32px 26px 30px 28px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  position: relative;
}
.tw-entry.inner .bubble::before,
.tw-entry.inner .bubble::after {
  content: "";
  position: absolute;
  background: rgba(255, 248, 230, 0.94);
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}
.tw-entry.inner .bubble::before {
  width: 14px; height: 14px;
  bottom: -10px;
  right: 24px;
}
.tw-entry.inner .bubble::after {
  width: 7px; height: 7px;
  bottom: -22px;
  right: 10px;
}
.tw-entry.inner .speaker {
  opacity: 0.55;
  font-style: italic;
  margin-right: 14px;
}

/* Claude가 답하기 직전 점 3개 인디케이터 */
.indicator {
  display: flex;
  align-items: flex-start;
  margin-bottom: 12px;
  animation: bubble-in 0.3s ease;
}
.indicator .bubble {
  background: #ffffff;
  border: 1px solid rgba(80, 60, 40, 0.15);
  padding: 12px 16px;
  border-radius: 16px;
  border-top-left-radius: 4px;
  display: flex;
  gap: 4px;
}
.indicator .dot {
  width: 6px; height: 6px;
  background: #a89178;
  border-radius: 50%;
  animation: bouncedot 1.2s infinite ease-in-out;
}
.indicator .dot:nth-child(2) { animation-delay: 0.15s; }
.indicator .dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes bouncedot {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.35; }
  40%           { transform: scale(1);   opacity: 1; }
}

@keyframes bubble-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.tw-footer {
  padding: 10px 16px;
  border-top: 1px solid rgba(80, 60, 40, 0.18);
  font-size: 11.5px;
  color: var(--ink-muted);
  font-family: system-ui, sans-serif;
  letter-spacing: 0.4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 32px;
}
.tw-pace { font-style: italic; opacity: 0.8; }

/* 배경 전환 버튼 (개발용 — 어느 에셋이 맞는지 비교) */
.bg-switch {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  gap: 6px;
  z-index: 6;
  font-family: system-ui, sans-serif;
}
.bg-switch button {
  background: rgba(20, 14, 8, 0.85);
  color: #d9a87a;
  border: 1px solid rgba(217, 154, 74, 0.3);
  padding: 7px 12px;
  font-size: 11.5px;
  letter-spacing: 0.5px;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.15s;
}
.bg-switch button:hover {
  background: rgba(40, 28, 16, 0.95);
  border-color: rgba(217, 154, 74, 0.6);
}
.bg-switch button.active {
  background: rgba(217, 154, 74, 0.2);
  border-color: rgba(217, 154, 74, 0.8);
  color: #f5d4a0;
}

/* 사이트 네비 (모든 페이지 공통) */
.site-nav {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 2px;
  background: rgba(15, 10, 6, 0.88);
  border: 1px solid rgba(217, 154, 74, 0.25);
  border-radius: 6px;
  padding: 4px;
  z-index: 8;
  backdrop-filter: blur(6px);
  font-family: system-ui, sans-serif;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
}
.site-nav a {
  color: #c9a87a;
  text-decoration: none;
  padding: 7px 14px;
  font-size: 12px;
  letter-spacing: 1.2px;
  border-radius: 3px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.site-nav a:hover { background: rgba(217, 154, 74, 0.12); color: #f5d4a0; }
.site-nav a.current {
  background: rgba(217, 154, 74, 0.22);
  color: #f5d4a0;
}
