:root {
  --bg: #b2c7da;
  --panel: #ffffff;
  --line: #d8dbe2;
  --text: #111111;
  --subtext: #5b5f67;
  --my-bubble: #fee500;
  --ai-bubble: #ffffff;
  --send: #392020;
  --send-text: #ffffff;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 20%, rgba(255, 255, 255, 0.26), transparent 30%),
    radial-gradient(circle at 88% 75%, rgba(255, 255, 255, 0.18), transparent 35%),
    var(--bg);
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 12px;
}

.phone-shell {
  width: min(420px, 100%);
  height: min(820px, calc(100vh - 24px));
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.18);
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: rgba(245, 246, 248, 0.95);
  border-bottom: 1px solid var(--line);
}

.room-label {
  margin: 0;
  font-size: 12px;
  color: var(--subtext);
}

.room-title {
  margin: 2px 0 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.topbar-btn {
  border: 0;
  border-radius: 10px;
  padding: 7px 11px;
  background: #eceff3;
  color: #2f3440;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.topbar-btn:hover {
  background: #e2e6ec;
}

.chat-window {
  padding: 14px 10px 18px;
  overflow-y: auto;
}

.message-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  animation: pop 0.2s ease-out;
}

.message-row.user {
  justify-content: flex-end;
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 11px;
  background: #2f3440;
  color: #fff;
  font-size: 11px;
  display: grid;
  place-items: center;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 4px;
}

.message-row.user .avatar {
  display: none;
}

.bubble-wrap {
  max-width: 80%;
}

.sender {
  margin: 0 0 4px;
  font-size: 11px;
  color: var(--subtext);
}

.bubble {
  margin: 0;
  padding: 10px 12px;
  border-radius: 4px 14px 14px 14px;
  background: var(--ai-bubble);
  box-shadow: 0 2px 9px rgba(0, 0, 0, 0.08);
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.message-row.user .bubble-wrap {
  display: flex;
  justify-content: flex-end;
}

.message-row.user .bubble {
  background: var(--my-bubble);
  border-radius: 14px 4px 14px 14px;
}

.typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 54px;
}

.typing-bubble span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8d93a0;
  display: inline-block;
  animation: typingDot 1s infinite ease-in-out;
}

.typing-bubble span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-bubble span:nth-child(3) {
  animation-delay: 0.3s;
}

.input-bar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--line);
  background: rgba(248, 249, 251, 0.95);
}

.input-bar input {
  border: 1px solid #cfd4dc;
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 15px;
  outline: none;
}

.input-bar input:focus {
  border-color: #9098a3;
}

.send-btn {
  border: 0;
  border-radius: 12px;
  padding: 0 14px;
  min-height: 44px;
  background: var(--send);
  color: var(--send-text);
  font-weight: 700;
  cursor: pointer;
}

.send-btn:hover {
  filter: brightness(1.08);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@keyframes pop {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes typingDot {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

@media (max-width: 520px) {
  body {
    padding: 0;
  }

  .phone-shell {
    width: 100%;
    height: 100vh;
    border-radius: 0;
  }
}
