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

:root {
  --bg: #ffffff;
  --border: #e8e8e7;
  --text: #1a1a1a;
  --text-muted: #8a8a8a;
  --text-light: #c0c0c0;
  --user-bg: #1a1a1a;
  --user-text: #ffffff;
  --claude-bg: #f4f4f3;
  --claude-text: #1a1a1a;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.6; }

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

/* Header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
}
.header-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.header-mailbox {
  font-size: 12px;
  color: var(--text-muted);
}
.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Status */
.status { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: #ccc; flex-shrink: 0; transition: background 0.3s; }
.status.online .status-dot { background: #22c55e; }
.status.offline .status-dot { background: #ef4444; }
.status.thinking .status-dot { background: #f59e0b; animation: pulse 1s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.btn-icon {
  width: 30px; height: 30px;
  border: 1px solid var(--border);
  background: none;
  border-radius: 7px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
}
.btn-icon:hover { background: #f4f4f3; color: var(--text); }

/* Messages */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Welcome */
.welcome {
  margin: auto;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}
.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 16px;
}
.suggestion {
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: none;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-muted);
  font-family: var(--font);
  transition: border-color 0.15s, color 0.15s;
}
.suggestion:hover { border-color: #aaa; color: var(--text); }

/* Bubbles */
.message { display: flex; gap: 10px; max-width: 100%; }
.message.user { flex-direction: row-reverse; }

.bubble {
  padding: 11px 15px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 85%;
}
.message.user .bubble {
  background: var(--user-bg);
  color: var(--user-text);
  border-radius: 14px 14px 4px 14px;
}
.message.claude .bubble {
  background: var(--claude-bg);
  color: var(--claude-text);
  border-radius: 14px 14px 14px 4px;
}

/* Typing dots */
.typing { display: flex; align-items: center; gap: 4px; padding: 4px 0; }
.typing span {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--text-light);
  animation: typing 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing { 0%,80%,100% { opacity: 0.3; transform: scale(1); } 40% { opacity: 1; transform: scale(1.2); } }

/* Code/JSON output */
.raw-output {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  background: #f8f8f7;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  white-space: pre;
}

/* Input */
.input-area {
  padding: 12px 20px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: #f4f4f3;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  transition: border-color 0.15s;
}
.input-wrapper:focus-within { border-color: #bbb; }

textarea {
  flex: 1;
  border: none;
  background: none;
  resize: none;
  outline: none;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  max-height: 140px;
  overflow-y: auto;
}
textarea::placeholder { color: var(--text-light); }

.send-btn {
  width: 32px; height: 32px;
  border: none;
  background: var(--text);
  color: white;
  border-radius: 9px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.send-btn:hover { opacity: 0.8; }

/* Markdown rendered content */
.markdown p { margin-bottom: 0.6em; }
.markdown p:last-child { margin-bottom: 0; }
.markdown ul, .markdown ol { padding-left: 1.4em; margin-bottom: 0.6em; }
.markdown li { margin-bottom: 0.2em; }
.markdown strong { font-weight: 600; }
.markdown em { font-style: italic; }
.markdown code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  background: rgba(0,0,0,0.06);
  border-radius: 4px;
  padding: 1px 5px;
}
.markdown pre {
  background: #f0f0ef;
  border-radius: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  margin: 6px 0;
}
.markdown pre code {
  background: none;
  padding: 0;
  font-size: 12px;
}
.markdown a { color: #1a1a1a; text-decoration: underline; }
.markdown table { border-collapse: collapse; width: 100%; margin: 6px 0; font-size: 13px; }
.markdown th, .markdown td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.markdown th { background: #f4f4f3; font-weight: 600; }
.markdown h1, .markdown h2, .markdown h3 { font-weight: 600; margin: 0.5em 0 0.3em; }
.markdown h1 { font-size: 16px; }
.markdown h2 { font-size: 15px; }
.markdown h3 { font-size: 14px; }

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
