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

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: #f0f2f5;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#app {
  width: 100%;
  max-width: 720px;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: #fff;
  box-shadow: 0 0 24px rgba(0,0,0,.08);
}

/* Header */
#header {
  background: #1a73e8;
  color: #fff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
#header .flag { font-size: 1.4rem; }
#header h1 { font-size: 1rem; font-weight: 600; }
#status-badge {
  margin-left: auto;
  background: rgba(255,255,255,.2);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: .75rem;
  white-space: nowrap;
}

/* Chat area */
#chat {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.msg {
  max-width: 90%;
  padding: 12px 16px;
  border-radius: 16px;
  line-height: 1.6;
  font-size: .92rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.bot {
  background: #f1f3f4;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.msg.user {
  background: #1a73e8;
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.msg.system {
  background: #fff3cd;
  border: 1px solid #ffc107;
  align-self: center;
  font-size: .85rem;
  border-radius: 10px;
  max-width: 95%;
}

/* Setup buttons */
.setup-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.setup-btn {
  background: #fff;
  border: 2px solid #1a73e8;
  color: #1a73e8;
  border-radius: 20px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: .88rem;
  font-weight: 600;
  transition: all .2s;
}
.setup-btn:hover, .setup-btn.selected {
  background: #1a73e8;
  color: #fff;
}

/* Typing indicator */
#typing {
  display: none;
  align-self: flex-start;
  background: #f1f3f4;
  border-radius: 16px;
  padding: 10px 16px;
  font-size: .85rem;
  color: #888;
}
#typing.show { display: block; }

/* Quick command chips */
#chips {
  display: flex;
  gap: 6px;
  padding: 8px 16px 4px;
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
}
#chips::-webkit-scrollbar { display: none; }
.chip {
  border: 1px solid #ddd;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: .8rem;
  cursor: pointer;
  white-space: nowrap;
  background: #fafafa;
  transition: background .15s;
}
.chip:hover { background: #e8f0fe; border-color: #1a73e8; color: #1a73e8; }

/* Input area */
#input-area {
  display: flex;
  gap: 8px;
  padding: 10px 14px 14px;
  border-top: 1px solid #eee;
  flex-shrink: 0;
}
#user-input {
  flex: 1;
  border: 1.5px solid #ddd;
  border-radius: 24px;
  padding: 10px 16px;
  font-size: .92rem;
  outline: none;
  resize: none;
  max-height: 120px;
  line-height: 1.4;
  font-family: inherit;
  transition: border .2s;
}
#user-input:focus { border-color: #1a73e8; }
#send-btn {
  background: #1a73e8;
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 1.2rem;
  cursor: pointer;
  flex-shrink: 0;
  align-self: flex-end;
  transition: background .2s;
}
#send-btn:hover { background: #1558b0; }
#send-btn:disabled { background: #ccc; cursor: default; }

/* Mic button */
#mic-btn {
  background: #f1f3f4;
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 1.2rem;
  cursor: pointer;
  flex-shrink: 0;
  align-self: flex-end;
  transition: background .2s;
}
#mic-btn:hover { background: #e0e0e0; }
#mic-btn.recording {
  background: #e53935;
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(229,57,53,.4); }
  50%       { box-shadow: 0 0 0 8px rgba(229,57,53,0); }
}

/* TTS / Gender toggle in header */
#tts-toggle, #gender-toggle {
  background: rgba(255,255,255,.15);
  border: none;
  border-radius: 20px;
  color: #fff;
  padding: 4px 10px;
  font-size: .95rem;
  cursor: pointer;
  transition: background .2s;
}
#tts-toggle { margin-left: auto; }
#tts-toggle:hover, #gender-toggle:hover { background: rgba(255,255,255,.3); }
#tts-toggle.off { opacity: .45; }
#gender-toggle { font-size: 1.1rem; }

/* Speaking indicator on bot messages */
.msg.bot.speaking {
  outline: 2px solid #1a73e8;
  outline-offset: 2px;
}

/* Replay button on bot messages — 모바일에서 탭하기 쉽게 */
.replay-btn {
  display: inline-block;
  margin-top: 10px;
  background: #1a73e8;
  border: none;
  border-radius: 20px;
  padding: 8px 18px;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  transition: background .15s;
  -webkit-tap-highlight-color: transparent;
}
.replay-btn:hover, .replay-btn:active { background: #1558b0; }
