:root {
  --bg: #b2c7d9;            /* KakaoTalk chat background */
  --topbar-bg: #ffffff;
  --bubble-other: #ffffff;
  --bubble-mine: #fee500;   /* Kakao yellow */
  --text: #191919;
  --muted: #555;
  --border: #d0dae3;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app {
  max-width: 480px;
  margin: 0 auto;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-left: 1px solid #a3b6c8;
  border-right: 1px solid #a3b6c8;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.title { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #ffe14b; border-radius: 50%; font-size: 20px;
}
.brand { font-weight: 700; font-size: 16px; }
.subtitle { font-size: 12px; color: var(--muted); margin-top: 2px; }

.actions { display: flex; gap: 6px; align-items: center; }
.icon-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  color: #555;
}
.icon-btn:hover { background: #f5f5f5; }
.icon-btn.active { background: #fee500; border-color: #fee500; color: #111; }

.new-btn {
  background: #fff; border: 1px solid var(--border); color: #333;
  padding: 6px 12px; border-radius: 16px; font-size: 13px; cursor: pointer;
}
.new-btn:hover { background: #f5f5f5; }

/* Quick action chips */
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  background: #eaf0f4;
  border-top: 1px solid var(--border);
  overflow-x: auto;
}
.quick-actions.hidden { display: none; }
.chip {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  color: #333;
}
.chip:hover { background: #fee500; border-color: #fee500; }

/* Chat area */
.chat {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.date-divider {
  text-align: center;
  margin: 4px 0 12px;
}
.date-divider span {
  display: inline-block;
  background: rgba(0,0,0,0.18);
  color: #fff;
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 12px;
}

/* Bubbles */
.row { display: flex; align-items: flex-end; gap: 6px; margin-top: 4px; }
.row.mine { justify-content: flex-end; }
.row.other { justify-content: flex-start; }
.avatar {
  width: 36px; height: 36px;
  background: #ffe14b;
  border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.bubble-wrap { max-width: 75%; display: flex; flex-direction: column; }
.row.mine .bubble-wrap { align-items: flex-end; }
.row.other .bubble-wrap { align-items: flex-start; }
.name {
  font-size: 12px;
  color: #333;
  margin: 0 4px 2px;
}
.bubble {
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-wrap;
  box-shadow: var(--shadow);
}
.row.other .bubble {
  background: var(--bubble-other);
  border-top-left-radius: 4px;
}
.row.mine .bubble {
  background: var(--bubble-mine);
  border-top-right-radius: 4px;
}
.meta {
  font-size: 10px;
  color: rgba(0,0,0,0.5);
  margin: 2px 4px 0;
}

/* Typing indicator */
.typing .bubble {
  background: #fff;
  display: inline-flex; gap: 4px; align-items: center;
}
.typing .dot {
  width: 6px; height: 6px; border-radius: 50%; background: #888;
  animation: blink 1.4s infinite both;
}
.typing .dot:nth-child(2) { animation-delay: 0.2s; }
.typing .dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink {
  0%, 80%, 100% { opacity: 0.2; }
  40% { opacity: 1; }
}

/* Composer */
.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 10px;
  background: #f7f7f7;
  border-top: 1px solid var(--border);
}
.composer textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 9px 12px;
  font: inherit;
  font-size: 14px;
  background: #fff;
  max-height: 120px;
  outline: none;
}
.composer textarea:focus { border-color: #999; }
.send-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: none;
  background: #fee500;
  font-weight: 700; font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
}
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Status footer in last assistant bubble (debug-only, hidden by default) */
.state-tag {
  display: none;
  margin: 4px 0 0;
  padding: 2px 8px;
  font-size: 11px;
  color: #555;
  background: rgba(255,255,255,0.6);
  border-radius: 8px;
}
body.debug .state-tag { display: inline-block; }

/* Session ended banner */
.ended-banner {
  margin: 12px auto;
  padding: 10px 14px;
  background: rgba(0,0,0,0.18);
  color: #fff;
  font-size: 12px;
  border-radius: 12px;
  text-align: center;
  max-width: 80%;
}

/* Demo info card (shown after welcome) */
.demo-card {
  margin: 4px 12px 0 56px;   /* avatar 너비 + gap 정도 들여쓰기 */
  padding: 10px 12px;
  background: #fffceb;
  border: 1px solid #fde68a;
  border-radius: 12px;
  font-size: 13px;
  color: #333;
  max-width: 78%;
}
.demo-card .head {
  font-weight: 700;
  font-size: 12px;
  color: #92400e;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.demo-card .row-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
  border-top: 1px dashed #fde68a;
}
.demo-card .row-item:first-of-type { border-top: none; }
.demo-card .label {
  font-size: 12px;
  color: #555;
  flex-shrink: 0;
}
.demo-card .serial {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  background: #fff;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid #fde68a;
  flex: 1;
  text-align: center;
  word-break: break-all;
}
.demo-card .copy-btn {
  background: #fee500;
  border: none;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  color: #111;
  flex-shrink: 0;
}
.demo-card .copy-btn:hover { background: #fcd900; }
.demo-card .copy-btn.copied { background: #d4edda; color: #155724; }
.demo-card .foot {
  font-size: 11px;
  color: #777;
  margin-top: 6px;
}
