/* Welcome */
.welcome-screen {
  display: flex; align-items: center; justify-content: center;
  padding: 40px 20px;
}
.input-area.welcome-active .welcome-screen {
  display: flex;
}
.input-area:not(.welcome-active) .welcome-screen {
  display: none;
}
.input-area:not(.welcome-active) .suggestion-chips {
  display: none;
}
.input-area:not(.welcome-active) .pro-banner {
  display: none !important;
}
.welcome-content { text-align: center; max-width: 420px; }
.welcome-logo-wrap { position: relative; display: inline-flex; margin-bottom: 28px; }
.welcome-logo-glow {
  position: absolute; inset: -20px;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  border-radius: 50%; animation: pulseGlow 3s ease-in-out infinite;
}
.welcome-logo {
  position: relative; width: 56px; height: 56px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-lg); background: var(--surface-1);
  border: 1px solid var(--border-1); color: var(--accent);
  box-shadow: var(--shadow-md);
}
.welcome-title { font-size: 26px; font-weight: 600; color: var(--text-primary); margin-bottom: 8px; letter-spacing: -0.3px; }
.welcome-subtitle { font-size: 16px; color: var(--text-secondary); line-height: 1.5; }

/* Messages */
.messages { display: flex; flex-direction: column; max-width: 760px; width: 100%; margin: 0 auto; padding: 24px 16px 0; }
.messages-spacer { flex: 1; min-height: 40px; }

.message {
  display: flex; gap: 14px; padding: 18px 0;
  animation: messageIn 0.35s cubic-bezier(0.4,0,0.2,1) both;
}
.message:last-child { border-bottom: none; }

.message-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; margin-top: 2px;
}
.message-avatar.user { background: var(--surface-3); color: var(--text-tertiary); }
.message-avatar.assistant {
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid var(--accent-glow);
}

.message-body { flex: 1; min-width: 0; }
.message-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.message-role { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.message-model {
  font-size: 14px; color: var(--text-muted); background: var(--surface-2);
  padding: 1px 6px; border-radius: 4px;
}
.message-text { font-size: 16px; line-height: 1.7; color: var(--text-secondary); word-wrap: break-word; }
.message-text p { margin-bottom: 12px; }
.message-text p:last-child { margin-bottom: 0; }
.message-text code {
  background: var(--surface-3); padding: 2px 6px; border-radius: 5px;
  font-family: 'SF Mono', ui-monospace, 'Cascadia Code', monospace;
  font-size: 14px; color: var(--text-primary);
}
.message-text pre {
  background: var(--surface-1); border: 1px solid var(--border-1);
  border-radius: var(--radius-md); overflow-x: auto; margin: 14px 0; position: relative;
}
.message-text pre code {
  display: block; padding: 16px; background: none;
  font-size: 14px; line-height: 1.6; overflow-x: auto;
}

.message-image {
  margin-top: 8px;
  border-radius: var(--radius-md);
  overflow: hidden;
}
.message-image img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
}

.code-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; background: var(--surface-2);
  border-bottom: 1px solid var(--border-1);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}
.code-lang {
  font-size: 12px; font-weight: 500; color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.code-copy {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 8px; background: none; border: 1px solid var(--border-1);
  border-radius: var(--radius-sm); color: var(--text-tertiary);
  font-size: 12px; cursor: pointer;
  transition: all var(--transition-fast); font-family: inherit;
}
.code-copy:hover { background: var(--surface-3); color: var(--text-primary); border-color: var(--border-2); }

.message-actions {
  display: flex; gap: 4px; margin-top: 10px;
  opacity: 0; transition: opacity var(--transition-fast);
}
.message:hover .message-actions { opacity: 1; }

.msg-action {
  padding: 4px 8px; border-radius: 6px; background: none; border: none;
  color: var(--text-muted); font-size: 15px; cursor: pointer;
  transition: all var(--transition-fast); font-family: inherit;
  display: flex; align-items: center; gap: 4px;
}
.msg-action:hover { background: var(--surface-2); color: var(--text-secondary); }
.msg-action svg { width: 16px; height: 16px; }

/* Loading / Thinking shimmer */
.thinking-text {
  font-size: 14px; font-weight: 500; letter-spacing: 0.2px;
  background: linear-gradient(
    90deg,
    var(--text-muted) 0%,
    var(--text-secondary) 25%,
    var(--text-primary) 50%,
    var(--text-secondary) 75%,
    var(--text-muted) 100%
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
  padding: 10px 0;
  animation: shimmerSweep 2.2s linear infinite;
}
@keyframes shimmerSweep {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Scroll-to-bottom button */
.scroll-to-bottom-btn {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 12px);
  transform: translateX(-50%) translateY(8px);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--scroll-btn-bg);
  border: 1px solid var(--border-1);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease, background 0.15s ease, color 0.15s ease;
  box-shadow: var(--shadow-md);
  z-index: 25;
}
.scroll-to-bottom-btn.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
.scroll-to-bottom-btn:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}
.scroll-to-bottom-btn.visible:active {
  transform: translateX(-50%) translateY(0) scale(0.92);
}

/* Input Area */
.input-area {
  padding: 0 16px 16px;
}
.input-area-inner { max-width: 760px; margin: 0 auto; }

.pro-banner {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 6px 0 10px; font-size: 13px; color: var(--text-muted);
}
.pro-banner svg { color: var(--warning); }

.input-box {
  background: var(--surface-1); border: 1px solid var(--border-1);
  border-radius: var(--radius-xl); padding: 10px 14px;
  transition: all var(--transition-fast); box-shadow: var(--shadow-sm);
}
.input-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow), var(--shadow-md);
}

.input-toolbar {
  display: flex; align-items: center; gap: 2px;
  margin-bottom: 6px; padding-bottom: 6px;
  border-bottom: 1px solid var(--border-1);
}
.toolbar-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 10px; border-radius: var(--radius-sm);
  background: none; border: none; color: var(--text-tertiary);
  font-size: 14px; font-weight: 500; cursor: pointer;
  transition: all var(--transition-fast); font-family: inherit;
}
.toolbar-btn .btn-text { display: none; }
.toolbar-btn:hover { background: var(--surface-2); color: var(--text-secondary); }
.toolbar-btn.active { background: var(--accent-soft); color: var(--accent); }
.toolbar-btn.active .btn-text { display: inline; }

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

#messageInput {
  flex: 1; background: none; border: none; color: var(--text-primary);
  font-size: 14.5px; line-height: 1.5; resize: none; outline: none;
  max-height: 180px; min-height: 22px; font-family: inherit; padding: 4px 0;
}
@media (min-width: 768px) {
  #messageInput {
    min-height: 66px;
  }
}
#messageInput::placeholder { color: var(--text-muted); }

.voice-btn {
  width: 32px; height: 32px; border-radius: 50%;
  background: none; border: none; color: var(--text-tertiary);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all var(--transition-fast); flex-shrink: 0; margin-bottom: 2px;
}
.voice-btn:hover { background: var(--surface-2); color: var(--text-secondary); }

.send-btn {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); border: none; color: white;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all var(--transition-fast); flex-shrink: 0; margin-bottom: 2px;
}
.send-btn:hover:not(:disabled) { background: var(--accent-hover); transform: scale(1.05); }
.send-btn:disabled { background: var(--surface-3); color: var(--text-muted); cursor: not-allowed; transform: none; }
.send-btn:active:not(:disabled) { transform: scale(0.95); }
.send-btn.stop-mode { background: #ef4444; }
.send-btn.stop-mode:hover { background: #dc2626; }

.aborted-notice {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 6px;
  font-size: 13px;
  color: #ef4444;
  font-weight: 500;
  margin-top: 8px;
}

/* Suggestion Chips */
.suggestion-chips {
  display: flex; flex-wrap: wrap; gap: 8px;
  justify-content: center; margin-top: 14px; padding: 0 8px;
}
.chip {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 13px; background: var(--surface-1);
  border: 1px solid var(--border-1); border-radius: 100px;
  color: var(--text-secondary); font-size: 14px; font-weight: 500;
  cursor: pointer; transition: all var(--transition-fast); font-family: inherit;
}
.chip:hover {
  background: var(--surface-2); border-color: var(--border-2);
  color: var(--text-primary); transform: translateY(-1px); box-shadow: var(--shadow-sm);
}
.chip:active { transform: scale(0.97); }
.chip svg { color: var(--text-tertiary); }
