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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #0d1117;
  color: #e6edf3;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: #161b22;
  border-bottom: 1px solid #30363d;
  flex-shrink: 0;
}

#header h1 {
  font-size: 16px;
  font-weight: 600;
  color: #58a6ff;
  letter-spacing: 0.5px;
}

#header-actions { display: flex; gap: 10px; align-items: center; }

#header a, #clear-btn {
  font-size: 13px;
  color: #8b949e;
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s;
}
#header a:hover, #clear-btn:hover { color: #e6edf3; background: #21262d; }

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

#messages::-webkit-scrollbar { width: 6px; }
#messages::-webkit-scrollbar-track { background: transparent; }
#messages::-webkit-scrollbar-thumb { background: #30363d; border-radius: 3px; }

.message { display: flex; gap: 10px; max-width: 85%; }
.message.user { align-self: flex-end; flex-direction: row-reverse; }
.message.zaku { align-self: flex-start; }

.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  flex-shrink: 0;
}
.message.zaku .avatar { background: #1f6feb; color: #fff; }
.message.user .avatar { background: #388bfd22; color: #58a6ff; border: 1px solid #1f6feb; }

.bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.message.zaku .bubble {
  background: #161b22;
  border: 1px solid #30363d;
  border-top-left-radius: 2px;
}
.message.user .bubble {
  background: #1f6feb;
  color: #fff;
  border-top-right-radius: 2px;
}

/* Code blocks inside messages */
.bubble code {
  font-family: 'Consolas', 'Monaco', monospace;
  background: #0d1117;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 13px;
}
.bubble pre {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 10px;
  overflow-x: auto;
  margin-top: 6px;
}
.bubble pre code { background: none; padding: 0; }

/* Thinking indicator */
.thinking .bubble { color: #8b949e; font-style: italic; }
.thinking .bubble::after {
  content: '▋';
  animation: blink 1s infinite;
}
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0; } }

/* Input area */
#input-area {
  padding: 14px 20px;
  background: #161b22;
  border-top: 1px solid #30363d;
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

#input {
  flex: 1;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 10px 14px;
  color: #e6edf3;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  min-height: 42px;
  max-height: 120px;
  outline: none;
  transition: border-color 0.2s;
}
#input:focus { border-color: #1f6feb; }
#input::placeholder { color: #484f58; }

#send-btn {
  background: #1f6feb;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0 18px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
  align-self: flex-end;
  height: 42px;
}
#send-btn:hover { background: #388bfd; }
#send-btn:disabled { background: #21262d; color: #484f58; cursor: not-allowed; }

/* Jamber */
#jamber-container {
  position: fixed;
  bottom: 80px;
  right: 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  pointer-events: none;
  z-index: 100;
}

#jamber-bubble {
  background: #f6c90e;
  color: #1a1a1a;
  font-size: 12px;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: 10px;
  border-bottom-right-radius: 2px;
  max-width: 180px;
  line-height: 1.4;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.3s, transform 0.3s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
#jamber-bubble.visible { opacity: 1; transform: translateY(0); }

#jamber-duck { font-size: 24px; line-height: 1; }

/* Error toast */
#error-toast {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: #da3633;
  color: #fff;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  display: none;
  z-index: 200;
}

/* Settings page */
.settings-page {
  max-width: 480px;
  margin: 60px auto;
  padding: 0 20px;
}
.settings-page h1 { font-size: 20px; color: #58a6ff; margin-bottom: 24px; }
.settings-page label { display: block; font-size: 13px; color: #8b949e; margin-bottom: 6px; }
.settings-page input[type="password"], .settings-page input[type="text"] {
  width: 100%; padding: 10px 12px;
  background: #161b22; border: 1px solid #30363d;
  border-radius: 6px; color: #e6edf3; font-size: 14px; outline: none;
  transition: border-color 0.2s;
}
.settings-page input:focus { border-color: #1f6feb; }
.settings-page button {
  margin-top: 14px;
  background: #1f6feb; color: #fff; border: none;
  border-radius: 6px; padding: 10px 20px;
  font-size: 14px; cursor: pointer; transition: background 0.2s;
}
.settings-page button:hover { background: #388bfd; }
.settings-page .status { margin-top: 12px; font-size: 13px; color: #3fb950; min-height: 20px; }
.settings-page .status.error { color: #f85149; }
.settings-page a { color: #58a6ff; text-decoration: none; font-size: 13px; }
.settings-page .note { font-size: 12px; color: #484f58; margin-top: 8px; line-height: 1.5; }
