:root {
  --bg: #f4f2ee;
  --surface: #ffffff;
  --text: #2b2723;
  --text-muted: #8a8478;
  --accent: #c47b3e;
  --accent-dark: #a3612c;
  --user-bubble: #c47b3e;
  --user-bubble-text: #ffffff;
  --assistant-bubble: #ffffff;
  --error-bubble: #fbeae7;
  --error-text: #a3402f;
  --border: #e5e0d8;
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 720px;
  margin: 0 auto;
  background: var(--bg);
}

.app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.header-avatar {
  font-size: 28px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f0e6d8;
  border-radius: 50%;
}

.header-text h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.header-subtitle {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.bubble-row {
  display: flex;
  flex-direction: column;
  max-width: 78%;
}

.bubble-row.user {
  align-self: flex-end;
  align-items: flex-end;
}

.bubble-row.assistant, .bubble-row.error {
  align-self: flex-start;
  align-items: flex-start;
}

.bubble {
  padding: 11px 16px;
  border-radius: var(--radius);
  font-size: 15px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble-row.user .bubble {
  background: var(--user-bubble);
  color: var(--user-bubble-text);
  border-bottom-right-radius: 4px;
}

.bubble-row.assistant .bubble {
  background: var(--assistant-bubble);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.bubble-row.error .bubble {
  background: var(--error-bubble);
  color: var(--error-text);
  border-bottom-left-radius: 4px;
}

.bubble-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  padding: 0 4px;
}

.retry-button {
  margin-top: 6px;
  border: 1px solid var(--error-text);
  background: transparent;
  color: var(--error-text);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  cursor: pointer;
}

.retry-button:hover {
  background: var(--error-text);
  color: white;
}

.attachment-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}

.attachment-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  background: rgba(0,0,0,0.06);
  border-radius: 10px;
  padding: 4px 8px;
  text-decoration: none;
  color: inherit;
}

.bubble-row.user .attachment-item {
  background: rgba(255,255,255,0.2);
}

.attachment-thumb {
  width: 90px;
  height: 90px;
  object-fit: cover;
  border-radius: 10px;
  display: block;
  margin-top: 6px;
}

.thinking {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
}

.thinking span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: bounce 1.2s infinite ease-in-out;
}

.thinking span:nth-child(2) { animation-delay: 0.15s; }
.thinking span:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

.composer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 12px 16px 16px;
}

.attachment-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.attachment-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12.5px;
}

.attachment-chip button {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
  padding: 0;
}

.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.icon-button {
  border: none;
  background: none;
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.icon-button:hover {
  background: var(--bg);
}

.icon-button.recording {
  background: var(--error-bubble);
  color: var(--error-text);
  animation: bounce 1s infinite ease-in-out;
}

.text-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 15px;
  font-family: inherit;
  resize: none;
  max-height: 140px;
  background: var(--bg);
  color: var(--text);
}

.text-input:focus {
  outline: none;
  border-color: var(--accent);
}

.send-button {
  border: none;
  background: var(--accent);
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.send-button:hover {
  background: var(--accent-dark);
}

.send-button:disabled {
  background: var(--border);
  cursor: not-allowed;
}

.text-input:disabled, .icon-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
