@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600&display=swap');

:root {
  --bg: #0f1115;
  --surface: #151922;
  --surface-elevated: #1b2130;
  --border: #2a3140;
  --border-hover: #3a4358;
  --text: #f3f4f6;
  --muted: #c4c9d4;
  --muted-strong: #9aa2b2;
  --accent: #10a37f;
  --accent-hover: #0f8b6f;
  --color-accent: var(--accent);
  --color-accent-hover: var(--accent-hover);
  --color-bg-primary: var(--bg);
  --color-bg-secondary: var(--surface);
  --color-bg-tertiary: var(--surface-elevated);
  --color-border: var(--border);
  --color-border-hover: var(--border-hover);
  --color-text-primary: var(--text);
  --color-text-secondary: var(--muted);
  --color-text-tertiary: var(--muted-strong);
  --color-user-message-bg: #2563eb;
  --color-user-message-text: #ffffff;
}

/* Light mode colors */
body.light-mode {
  --bg: #fdfcff;
  --surface: #f3f4f6;
  --surface-elevated: #e5e7eb;
  --border: #d4d8e1;
  --border-hover: #b6bfcd;
  --text: #111827;
  --muted: #4b5563;
  --muted-strong: #6b7280;
  --color-user-message-bg: #2563eb;
  --color-user-message-text: #ffffff;
}

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

:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

body {
  font-family: 'Space Grotesk', 'Segoe UI', sans-serif;
  background-color: var(--color-bg-primary);
  background-image:
    radial-gradient(circle at 25% 25%, rgba(16, 163, 127, 0.08), transparent 50%),
    radial-gradient(circle at 75% 75%, rgba(37, 99, 235, 0.06), transparent 50%),
    radial-gradient(circle at 50% 100%, rgba(139, 92, 246, 0.04), transparent 50%);
  color: var(--color-text-primary);
  font-size: 16px;
  line-height: 1.65;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.skip-link {
  background-color: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  color: var(--color-text-primary);
  left: 50%;
  padding: 0.5rem 1rem;
  position: absolute;
  top: -3rem;
  transform: translateX(-50%);
  transition: top 0.2s ease;
  z-index: 30;
}

.skip-link:focus {
  top: 0.75rem;
}

.skip-link:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.app-shell {
  display: flex;
  height: 100vh;
  width: 100%;
}

.sidebar {
  background-color: var(--color-bg-secondary);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  padding: 0;
  transition: width 0.2s ease;
  width: 280px;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.08);
}

.sidebar-header {
  align-items: center;
  display: flex;
  padding: 0.75rem;
  gap: 0.5rem;
}

.sidebar-new-chat {
  align-items: center;
  background-color: var(--color-accent);
  border: 1px solid transparent;
  border-radius: 8px;
  color: #ffffff;
  cursor: pointer;
  display: flex;
  flex: 1;
  font-size: 0.875rem;
  font-weight: 500;
  gap: 0.5rem;
  justify-content: center;
  padding: 0.5rem;
  transition: background-color 0.2s ease, transform 0.1s ease;
}

.sidebar-new-chat:hover {
  background-color: var(--color-accent-hover);
  transform: translateY(-1px);
}

.sidebar-new-icon {
  font-size: 1rem;
  font-weight: 300;
  line-height: 1;
}

.sidebar-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.chat-history {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.chat-history-header {
  padding: 0 0.75rem 0.5rem;
}

.chat-history-header h3 {
  color: var(--color-text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  margin: 0;
  text-transform: uppercase;
}

.chat-list {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  overflow-y: auto;
  padding: 0 0.75rem;
  scrollbar-width: thin;
}

.chat-list::-webkit-scrollbar {
  width: 4px;
}

.chat-list::-webkit-scrollbar-track {
  background: transparent;
}

.chat-list::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 2px;
}

.chat-item {
  align-items: flex-start;
  background-color: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--color-text-primary);
  cursor: pointer;
  display: flex;
  padding: 0.75rem;
  text-align: left;
  transition: all 0.2s ease;
  width: 100%;
}

.chat-item:hover {
  background-color: var(--color-bg-tertiary);
  border-color: var(--color-border);
  transform: translateX(1px);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.chat-item.active {
  background-color: rgba(16, 163, 127, 0.1);
  border-color: rgba(16, 163, 127, 0.3);
  box-shadow: inset 0 1px 2px rgba(16, 163, 127, 0.1);
}

.chat-item.active {
  background-color: rgba(16, 163, 127, 0.1);
  border-color: rgba(16, 163, 127, 0.3);
}

.chat-item-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 0.25rem;
  min-width: 0;
}

.chat-item-title {
  color: var(--color-text-primary);
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-item-time {
  color: var(--color-text-tertiary);
  font-size: 0.75rem;
  font-weight: 400;
}

.chat-delete-button {
  background-color: transparent;
  border: none;
  color: var(--color-text-tertiary);
  cursor: pointer;
  font-size: 1rem;
  opacity: 0;
  padding: 0.25rem 0.5rem;
  transition: all 0.2s ease;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 4px;
}

.chat-item:hover .chat-delete-button {
  opacity: 1;
}

.chat-delete-button:hover {
  background-color: var(--color-danger-background, rgba(239, 68, 68, 0.1));
  color: var(--color-danger, #ef4444);
}

.chat-list-empty {
  padding: 1rem;
  text-align: center;
  color: var(--color-text-tertiary);
  font-size: 0.875rem;
}

.sidebar-nav {
  border-top: 1px solid var(--color-border);
  padding: 0.5rem 0.75rem;
}

.sidebar-item {
  align-items: center;
  background-color: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--color-text-primary);
  cursor: pointer;
  display: flex;
  font-size: 0.875rem;
  gap: 0.5rem;
  justify-content: flex-start;
  padding: 0.5rem 0.75rem;
  position: relative;
  text-align: left;
  transition: all 0.2s ease;
  width: 100%;
}

.sidebar-item:hover {
  background-color: var(--color-bg-tertiary);
  border-color: var(--color-border);
  transform: translateX(2px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.sidebar-item:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.sidebar-item-icon {
  font-size: 1rem;
  line-height: 1;
}

.sidebar-item-text {
  flex: 1;
}

.sidebar-footer {
  border-top: 1px solid var(--color-border);
  padding: 0.75rem;
}

body.sidebar-collapsed .sidebar {
  width: 76px;
}

body.sidebar-collapsed .sidebar-new-text,
body.sidebar-collapsed .sidebar-item-text,
body.sidebar-collapsed .chat-item-content,
body.sidebar-collapsed .chat-history-header {
  display: none;
}

body.sidebar-collapsed .sidebar-new-chat {
  justify-content: center;
  padding: 0.75rem;
}

body.sidebar-collapsed .sidebar-new-chat .sidebar-new-text {
  display: none;
}

body.sidebar-collapsed .chat-list {
  padding: 0 0.25rem;
}

body.sidebar-collapsed .chat-item {
  justify-content: center;
  padding: 0.75rem 0.5rem;
}

body.sidebar-collapsed .sidebar-nav,
body.sidebar-collapsed .sidebar-footer {
  padding-left: 0.25rem;
  padding-right: 0.25rem;
}

body.sidebar-collapsed .sidebar-item {
  justify-content: center;
  padding: 0.75rem 0.5rem;
  transform: none;
}

body.sidebar-collapsed .sidebar-item:hover {
  transform: none;
}

body.sidebar-collapsed .sidebar-toggle {
  margin-left: auto;
}

.sidebar-backdrop {
  background-color: rgba(10, 12, 16, 0.5);
  inset: 0;
  position: fixed;
  z-index: 25;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.sidebar-backdrop.hidden {
  opacity: 0;
  pointer-events: none;
}

body.sidebar-open .sidebar-backdrop {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.sidebar-toggle {
  background-color: transparent;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-text-primary);
  cursor: pointer;
  height: 32px;
  width: 32px;
  margin-left: auto;
}

.sidebar-toggle-main {
  background-color: transparent;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-text-primary);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  height: 36px;
  width: 36px;
  padding: 0;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  margin: 0;
  max-width: none;
  width: 100%;
}

.main-panel {
  background-color: var(--color-bg-primary);
  flex: 1;
}

.main-content {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

header {
  align-items: center;
  background-color: var(--color-bg-primary);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  padding: 0.875rem 1.25rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-left {
  align-items: center;
  display: flex;
  gap: 1rem;
  flex: 1;
  min-width: 0;
}

.header-right {
  align-items: center;
  display: flex;
  gap: 0.5rem;
}

header h1 {
  color: var(--color-text-primary);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 0;
}

.theme-toggle {
  align-items: center;
  background-color: transparent;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-text-primary);
  cursor: pointer;
  display: flex;
  height: 36px;
  justify-content: center;
  transition: all 0.2s ease;
  width: 36px;
}

.theme-toggle:hover {
  background-color: var(--color-bg-secondary);
  border-color: var(--color-border-hover);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.theme-icon {
  height: 20px;
  width: 20px;
}

body.light-mode .sun-icon {
  display: none;
}

body.light-mode .moon-icon {
  display: block !important;
}

.user-menu {
  align-items: center;
  background-color: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-text-primary);
  cursor: pointer;
  display: flex;
  height: 36px;
  justify-content: center;
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
  width: 36px;
}

.user-menu:hover {
  background-color: var(--color-bg-tertiary);
  border-color: var(--color-border-hover);
  transform: translateY(-1px);
}

.user-menu:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.user-avatar {
  align-items: center;
  background-color: var(--color-accent);
  border-radius: 50%;
  color: #ffffff;
  display: flex;
  font-size: 0.875rem;
  font-weight: 600;
  height: 28px;
  justify-content: center;
  width: 28px;
}

.model-selector {
  align-items: center;
  display: flex;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
}

.model-input-container {
  position: relative;
  width: 100%;
  min-width: 160px;
  max-width: 320px;
}

.model-input-container input {
  background-color: var(--color-bg-secondary);
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--color-text-primary);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  overflow: hidden;
  padding: 0.5rem 2.25rem 0.5rem 1rem;
  text-overflow: ellipsis;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
  white-space: nowrap;
  width: 100%;
}

.model-input-container::after {
  color: var(--color-text-tertiary);
  content: '▾';
  font-size: 0.85rem;
  pointer-events: none;
  position: absolute;
  right: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
}

.model-input-container input:hover {
  background-color: var(--color-bg-tertiary);
  border-color: var(--color-border);
  transform: translateY(-0.5px);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.model-input-container input:focus {
  background-color: var(--color-bg-secondary);
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.12);
  outline: none;
  transform: translateY(-0.5px);
}

.model-input-container input::placeholder {
  color: var(--color-text-tertiary);
}

.model-dropdown {
  background-color: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.2);
  left: 0;
  margin-top: 0.375rem;
  max-height: 400px;
  overflow-y: auto;
  position: absolute;
  top: 100%;
  width: 100%;
  z-index: 1000;
}

.model-dropdown.hidden {
  display: none;
}

.model-dropdown::-webkit-scrollbar {
  width: 8px;
}

.model-dropdown::-webkit-scrollbar-track {
  background: transparent;
}

.model-dropdown::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 4px;
}

.model-dropdown::-webkit-scrollbar-thumb:hover {
  background: var(--color-border-hover);
}

.model-dropdown-group {
  color: var(--color-text-tertiary);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 0.75rem 0.875rem 0.5rem;
  text-transform: uppercase;
}

.model-dropdown-item {
  cursor: pointer;
  padding: 0.875rem;
  transition: background-color 0.1s ease;
}

.model-dropdown-item:not(:last-child) {
  border-bottom: 1px solid var(--color-border);
}

.model-dropdown-item:hover {
  background-color: var(--color-bg-tertiary);
}

.model-dropdown-item.selected {
  background-color: var(--color-accent);
  color: #ffffff;
}

.model-dropdown-item-name {
  color: var(--color-text-primary);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.5;
}

.model-dropdown-item.selected .model-dropdown-item-name {
  color: #ffffff;
}

.model-dropdown-item-id {
  color: var(--color-text-secondary);
  font-size: 0.75rem;
  line-height: 1.5;
  margin-top: 0.25rem;
  opacity: 0.8;
}

.model-dropdown-item.selected .model-dropdown-item-id {
  color: rgba(255, 255, 255, 0.85);
  opacity: 1;
}

.model-dropdown-loading,
.model-dropdown-empty {
  color: var(--color-text-secondary);
  font-size: 0.875rem;
  padding: 1rem 0.875rem;
  text-align: center;
}

.chat-container {
  background-color: var(--color-bg-primary);
  display: flex;
  flex: 1;
  flex-direction: column;
  overflow-y: auto;
  padding: 2.5rem 2rem;
  scrollbar-color: var(--color-border) transparent;
  scrollbar-width: thin;
}

.chat-container::-webkit-scrollbar {
  width: 8px;
}

.chat-container::-webkit-scrollbar-track {
  background: transparent;
}

.chat-container::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 4px;
}

.chat-container::-webkit-scrollbar-thumb:hover {
  background: var(--color-border-hover);
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  flex: 1;
  margin: 0 auto;
  max-width: 48rem;
  width: 100%;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  padding: 3rem 2rem;
  opacity: 0.95;
}

.empty-state h2 {
  color: var(--color-text-primary);
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.2;
  margin-bottom: 0.75rem;
}

.empty-state p {
  color: var(--color-text-secondary);
  font-size: 1rem;
  margin-bottom: 2rem;
  max-width: 400px;
}

.empty-state-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 1.5rem;
  max-width: 640px;
  width: 100%;
}

.suggestion-chip {
  background-color: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  color: var(--color-text-primary);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.6rem 1rem;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.suggestion-chip:hover {
  background-color: var(--color-bg-tertiary);
  border-color: var(--color-border-hover);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.suggestion-chip:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.message {
  animation: fadeIn 0.4s ease-out;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  max-width: 100%;
  padding: 0.75rem 1rem;
  position: relative;
  transition: all 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.user {
  align-self: flex-end;
  background-color: var(--color-user-message-bg);
  color: var(--color-user-message-text);
  margin-left: 2rem;
  max-width: 80%;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.15);
}

.message.assistant {
  align-self: flex-start;
  background-color: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  color: var(--color-text-primary);
  margin-right: 2rem;
  max-width: 80%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.message-header {
  align-items: center;
  display: flex;
  font-size: 0.75rem;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  opacity: 0.8;
}

.message-meta {
  align-items: center;
  display: flex;
  gap: 0.5rem;
}

.message-role {
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: capitalize;
}

.message-timestamp {
  font-size: 0.75rem;
  font-weight: 400;
}

.message-copy-button {
  align-items: center;
  background-color: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: currentColor;
  cursor: pointer;
  display: flex;
  height: 28px;
  justify-content: center;
  opacity: 0;
  padding: 0;
  transition: opacity 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
  width: 28px;
}

.message:hover .message-copy-button {
  opacity: 0.7;
}

.message-copy-button:hover {
  background-color: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.3);
  opacity: 1 !important;
}

.message.user .message-copy-button:hover {
  background-color: rgba(255, 255, 255, 0.3);
}

.message-copy-icon {
  height: 14px;
  width: 14px;
}

.message-feedback {
  display: flex;
  gap: 0.25rem;
  margin-left: auto;
}

.feedback-btn, .regenerate-btn {
  align-items: center;
  background-color: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--color-text-tertiary);
  cursor: pointer;
  display: flex;
  height: 24px;
  justify-content: center;
  padding: 0;
  transition: all 0.2s ease;
  width: 24px;
}

.feedback-btn:hover, .regenerate-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
  border-color: var(--color-border);
  color: var(--color-text-secondary);
}

.feedback-btn:active, .regenerate-btn:active {
  transform: scale(0.95);
}

.feedback-btn svg, .regenerate-btn svg {
  height: 14px;
  width: 14px;
}

.message-content {
  line-height: 1.55;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.message-content p {
  margin-bottom: 0.5rem;
}

.message-content p:last-child {
  margin-bottom: 0;
}

.message-content strong {
  font-weight: 600;
}

.message-content em {
  font-style: italic;
}

.message-content code {
  background-color: var(--color-bg-tertiary);
  border-radius: 4px;
  color: #e8eaed;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.875em;
  padding: 0.2rem 0.4rem;
}

.message-content pre {
  background-color: #1a1a1a;
  border: 1px solid var(--color-bg-tertiary);
  border-radius: 8px;
  margin: 0.75rem 0;
  overflow-x: auto;
  padding: 1rem;
  position: relative;
}

.message-content pre code {
  background-color: transparent;
  padding: 0;
  border-radius: 0;
  display: block;
  font-size: 0.875rem;
  line-height: 1.5;
}

.code-block-wrapper {
  position: relative;
  margin: 0.5rem 0;
}

.copy-button {
  background-color: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  color: var(--color-text-primary);
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.4rem 0.8rem;
  position: absolute;
  right: 0.5rem;
  top: 0.5rem;
  transition: background-color 0.2s, border-color 0.2s;
}

.copy-button:hover {
  background-color: var(--color-border);
  border-color: var(--color-border-hover);
}

.copy-button.copied {
  background-color: var(--color-accent);
  border-color: var(--color-accent);
  color: #ffffff;
}

.input-area {
  background-color: var(--color-bg-primary);
  border-top: 1px solid var(--color-border);
  bottom: 0;
  display: flex;
  justify-content: center;
  padding: 1.25rem 1.5rem;
  position: sticky;
  z-index: 15;
}

.build-info {
  background-color: var(--color-bg-primary);
  border-top: 1px solid var(--color-bg-secondary);
  color: var(--color-text-tertiary);
  font-size: 0.75rem;
  padding: 0.5rem 1rem 0.75rem;
  text-align: center;
}

.modal {
  align-items: center;
  background-color: rgba(10, 12, 16, 0.6);
  display: flex;
  inset: 0;
  justify-content: center;
  position: fixed;
  z-index: 40;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background-color: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  max-width: 420px;
  padding: 1.5rem;
  width: 90%;
}

.modal-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.modal-header h2 {
  font-size: 1.2rem;
  font-weight: 600;
}

.modal-close {
  background-color: transparent;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-text-primary);
  cursor: pointer;
  height: 32px;
  width: 32px;
}

.settings-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.settings-section:last-child {
  margin-bottom: 0;
}

.settings-section h3 {
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.settings-section label {
  color: var(--color-text-tertiary);
  font-size: 0.8rem;
}

.settings-section select {
  background-color: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  color: var(--color-text-primary);
  font-family: inherit;
  padding: 0.5rem 0.75rem;
}

.accent-options {
  display: flex;
  gap: 0.75rem;
}

.accent-swatch {
  border: 2px solid transparent;
  border-radius: 50%;
  cursor: pointer;
  height: 28px;
  width: 28px;
}

.accent-swatch[data-accent='emerald'] {
  background-color: #10a37f;
}

.accent-swatch[data-accent='sky'] {
  background-color: #38bdf8;
}

.accent-swatch[data-accent='violet'] {
  background-color: #8b5cf6;
}

.accent-swatch[data-accent='amber'] {
  background-color: #f59e0b;
}

.accent-swatch.active {
  border-color: #ffffff;
}

.composer {
  align-items: center;
  background-color: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.08);
  display: grid;
  gap: 0.5rem;
  grid-template-columns: auto 1fr auto;
  max-width: 880px;
  padding: 0.75rem 1rem;
  width: 100%;
  transition: all 0.2s ease;
}

.composer:focus-within {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.12), 0 4px 12px rgba(0, 0, 0, 0.15);
}

.composer-btn {
  background-color: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--color-text-primary);
  cursor: pointer;
  font-size: 1rem;
  height: 36px;
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
  width: 36px;
}

.composer-btn:hover {
  background-color: var(--color-bg-tertiary);
  border-color: var(--color-border);
  transform: translateY(-1px);
}

.composer-btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.composer-input {
  display: flex;
  flex: 1;
  min-width: 0;
}

#user-input {
  background-color: transparent;
  border: none;
  border-radius: 0;
  color: var(--color-text-primary);
  flex: 1;
  font-family: inherit;
  font-size: 0.9375rem;
  line-height: 1.5;
  max-height: 200px;
  min-height: 36px;
  overflow-y: auto;
  padding: 0.5rem 0.25rem;
  resize: none;
  transition: box-shadow 0.2s ease;
}

#user-input:focus {
  box-shadow: 0 0 0 2px rgba(16, 163, 127, 0.2);
  outline: none;
}

#user-input::placeholder {
  color: var(--color-text-tertiary);
}

#send-button {
  align-items: center;
  background-color: var(--color-accent);
  border: 1px solid transparent;
  border-radius: 999px;
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  font-size: 0.95rem;
  font-weight: 600;
  height: 36px;
  justify-content: center;
  padding: 0;
  transition: all 0.2s ease;
  width: 36px;
}

.composer-icon {
  height: 18px;
  width: 18px;
  transition: all 0.2s ease;
}

#send-button:hover:not(:disabled) {
  background-color: var(--color-accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(16, 163, 127, 0.3);
}

#send-button:active:not(:disabled) {
  transform: scale(0.98);
}

#send-button:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

#send-button:disabled {
  background-color: var(--color-border);
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
  box-shadow: none;
}

#send-button.loading {
  animation: pulse 1.5s ease-in-out infinite;
}

.error-message {
  background-color: #3d2424;
  color: #f8b4b4;
  padding: 1rem;
  border-radius: 8px;
  margin: 1rem 0;
  border-left: 3px solid #ef4444;
  font-size: 0.9375rem;
}

.loading {
  animation: pulse 1.5s ease-in-out infinite;
  background-color: var(--color-accent);
  border-radius: 50%;
  display: inline-block;
  height: 8px;
  width: 8px;
}

@keyframes pulse {
  0%, 100% {
    opacity: 0.4;
  }
  50% {
    opacity: 1;
  }
}

.typing-indicator {
  align-items: flex-start;
  animation: fadeIn 0.3s ease-out;
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  padding: 0.25rem 0;
}

.typing-indicator.hidden {
  display: none;
}

.typing-avatar {
  align-items: center;
  background-color: var(--color-accent);
  border-radius: 50%;
  color: #ffffff;
  display: flex;
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 600;
  height: 24px;
  justify-content: center;
  width: 24px;
}

.typing-content {
  background-color: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  padding: 0.75rem 1rem;
}

.typing-dots {
  display: flex;
  gap: 0.25rem;
}

.typing-dot {
  animation: typing 1.4s ease-in-out infinite;
  background-color: var(--color-text-tertiary);
  border-radius: 50%;
  height: 6px;
  width: 6px;
}

.typing-dot:nth-child(1) {
  animation-delay: 0s;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%, 60%, 100% {
    opacity: 0.4;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-4px);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 900px) {
  .app-shell {
    flex-direction: column;
  }

  .sidebar {
    border-right: none;
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.4);
    left: 0;
    position: fixed;
    top: 0;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 30;
    height: 100vh;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-toggle-main {
    display: inline-flex;
    margin-right: 0.25rem;
    min-height: 44px;
    min-width: 44px;
  }

  .sidebar-toggle {
    display: none;
  }

  .sidebar-backdrop {
    transition: opacity 0.25s ease;
  }
}

@media (max-width: 768px) {
  header {
    padding: 0.625rem 1rem;
  }

  .header-left {
    gap: 0.5rem;
  }

  .model-input-container {
    max-width: 100%;
    min-width: 0;
    flex: 1;
  }

  #model-input {
    width: 100%;
    min-width: 0;
  }

  .message {
    border-radius: 12px;
    margin-bottom: 1.5rem;
    max-width: 95%;
    padding: 0.875rem 1rem;
  }

  .message.user {
    margin-left: 0.5rem;
    max-width: 90%;
  }

  .message.assistant {
    margin-right: 0.5rem;
    max-width: 90%;
  }

  .input-area {
    padding: 1rem;
  }

  .composer {
    padding: 0.625rem 0.875rem;
  }

  #send-button {
    height: 36px;
    min-height: 44px;
    min-width: 44px;
    width: 36px;
  }

  .empty-state {
    padding: 2rem 1rem;
  }

  .empty-state h2 {
    font-size: 1.5rem;
  }

  .empty-state p {
    font-size: 0.9375rem;
  }

  .empty-state-suggestions {
    gap: 0.5rem;
    max-width: 100%;
  }

  .suggestion-chip {
    font-size: 0.875rem;
    min-height: 44px;
    padding: 0.625rem 1rem;
  }

  /* Improve touch targets for mobile */
  .sidebar-item, .chat-item, .feedback-btn, .regenerate-btn, .message-copy-button {
    min-height: 44px;
    min-width: 44px;
  }

  .sidebar-toggle, .user-menu, .theme-toggle {
    min-height: 44px;
    min-width: 44px;
  }
}
