/* ============================================================
   AI Chat — HomeNode
   Claude-inspired layout · HomeNode design tokens
   ============================================================ */

/* ─── Tokens (inherit from HomeNode) ─────────────────────── */
:root {
  --sidebar-w: 280px;
  --topbar-h: 52px;
  --composer-max-h: 200px;

  /* status */
  --status-streaming: var(--emerald);
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Outfit', system-ui, sans-serif;
  background: var(--paper, #120d09);
  color: var(--text, #f4eae0);
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ─── body noise overlay (borrowed from styles.css) ──────── */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(680px 480px at 88% -6%, rgba(226,146,74,0.16), transparent 60%),
    radial-gradient(560px 420px at -8% 28%, rgba(47,191,133,0.08), transparent 60%),
    radial-gradient(900px 700px at 50% 110%, rgba(226,146,74,0.07), transparent 60%);
}

/* ─── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: rgba(18, 13, 9, 0.92);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  border-right: 1px solid var(--border, rgba(232,178,122,0.10));
  z-index: 100;
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--emerald, #2fbf85);
  cursor: pointer;
  text-decoration: none;
}

.brand-emblem-sm {
  width: 22px; height: 22px; flex-shrink: 0;
  position: relative;
  background: var(--emerald);
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(47,191,133,0.3);
}

.sidebar-close {
  display: none;
  width: 28px; height: 28px;
  align-items: center; justify-content: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-3, #97826f);
  cursor: pointer;
  transition: all 0.15s;
}

.sidebar-close:hover { color: var(--text); border-color: var(--border-md); }

/* New Chat Button */
.new-chat-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 12px 14px;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border, rgba(232,178,122,0.10));
  background: rgba(47, 191, 133, 0.08);
  color: var(--emerald);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.22, 1, 0.36, 1);
  flex-shrink: 0;
}

.new-chat-btn:hover {
  background: rgba(47, 191, 133, 0.15);
  border-color: rgba(47, 191, 133, 0.3);
}

/* Search */
.sidebar-search {
  position: relative;
  margin: 0 14px 8px;
  flex-shrink: 0;
}

.sidebar-search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
}

.sidebar-search-input {
  width: 100%;
  padding: 8px 8px 8px 34px;
  font-size: 0.78rem;
  color: var(--text);
  background: var(--surface-2, #241b12);
  border: 1px solid var(--border, rgba(232,178,122,0.10));
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
}

.sidebar-search-input::placeholder { color: var(--text-3); }
.sidebar-search-input:focus { border-color: var(--amber, #e2924a); }

/* Conversation List */
.conversation-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) transparent;
}

.conversation-list::-webkit-scrollbar { width: 6px; }
.conversation-list::-webkit-scrollbar-track { background: transparent; }
.conversation-list::-webkit-scrollbar-thumb {
  background: var(--surface-3); border-radius: 3px;
}

.conv-list-empty {
  padding: 32px 16px;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-3);
}

/* Conversation Group */
.conv-group-label {
  padding: 16px 10px 4px;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--amber, #e2924a);
}

.conv-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s;
  position: relative;
}

.conv-item:hover { background: var(--surface-2, #241b12); }
.conv-item.active {
  background: rgba(226, 146, 74, 0.10);
  border: 1px solid rgba(226, 146, 74, 0.18);
}

.conv-item-title {
  flex: 1;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-2, #cbb6a4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.conv-item.active .conv-item-title { color: var(--text); }

.conv-item-actions {
  display: none;
  gap: 2px;
  flex-shrink: 0;
}

.conv-item:hover .conv-item-actions { display: flex; }

.conv-item-action {
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  border: none; border-radius: 4px;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  font-size: 0.65rem;
  transition: all 0.12s;
}

.conv-item-action:hover { color: var(--text); background: var(--surface-3); }
.conv-item-action.danger:hover { color: var(--danger, #ff6b5b); }

/* Rename input */
.conv-rename-input {
  flex: 1;
  font-size: 0.78rem;
  padding: 2px 6px;
  background: var(--surface-2);
  border: 1px solid var(--amber);
  border-radius: 4px;
  color: var(--text);
  outline: none;
  font-family: inherit;
}

/* Sidebar Footer */
.sidebar-footer {
  display: flex;
  gap: 4px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-footer-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-3);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.sidebar-footer-btn:hover {
  color: var(--text);
  border-color: var(--border-md, rgba(232,178,122,0.20));
  background: var(--surface-2);
}

/* Sidebar Backdrop (mobile) */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99;
  background: rgba(14, 10, 7, 0.5);
  backdrop-filter: blur(4px);
}

/* ─── Main Chat Area ──────────────────────────────────────── */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  min-width: 0;
}

/* Top Bar */
.chat-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-h);
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(18, 13, 9, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  flex-shrink: 0;
}

.topbar-menu-btn {
  display: none;
  width: 34px; height: 34px;
  align-items: center; justify-content: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
}

.topbar-menu-btn:hover { background: var(--surface-2); border-color: var(--border-md); }

.topbar-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.topbar-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-model {
  font-size: 0.7rem;
  color: var(--text-3);
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--surface-2);
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.topbar-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: all 0.15s;
}

.topbar-btn:hover { color: var(--text); background: var(--surface-2); border-color: var(--border-md); }

/* ─── Messages Area ───────────────────────────────────────── */
.messages-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) transparent;
}

.messages-area::-webkit-scrollbar { width: 6px; }
.messages-area::-webkit-scrollbar-track { background: transparent; }
.messages-area::-webkit-scrollbar-thumb {
  background: var(--surface-3); border-radius: 3px;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  height: 100%;
  padding: 40px 24px;
  animation: fade-in 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.empty-icon {
  width: 64px; height: 64px;
  border-radius: 16px;
  background: rgba(47, 191, 133, 0.08);
  display: flex; align-items: center; justify-content: center;
  color: var(--emerald);
  margin-bottom: 20px;
}

.empty-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.empty-sub {
  font-size: 0.88rem;
  color: var(--text-3);
  max-width: 360px;
  line-height: 1.5;
  margin-bottom: 24px;
}

.empty-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-width: 480px;
}

.suggestion-chip {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border, rgba(232,178,122,0.10));
  background: var(--surface, #1c140d);
  color: var(--text-2);
  font-family: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s;
}

.suggestion-chip:hover {
  border-color: var(--amber);
  background: rgba(226,146,74,0.10);
  color: var(--text);
}

.empty-model-info {
  margin-top: 16px;
  font-size: 0.72rem;
  color: var(--text-4, #5e4e40);
}

/* Messages Container */
.messages-container {
  padding: 24px 16px 0;
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
}

/* Message */
.message {
  display: flex;
  gap: 14px;
  padding: 16px 0;
  opacity: 0;
  transform: translateY(8px);
  animation: msg-enter 0.25s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes msg-enter {
  to { opacity: 1; transform: translateY(0); }
}

.message:not(:last-child) {
  border-bottom: 1px solid rgba(232, 178, 122, 0.05);
}

.message-avatar {
  width: 30px; height: 30px;
  border-radius: 8px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  margin-top: 2px;
}

.message-avatar.user {
  background: rgba(226, 146, 74, 0.15);
  color: var(--amber);
}

.message-avatar.assistant {
  background: rgba(47, 191, 133, 0.12);
  color: var(--emerald);
}

.message-body {
  flex: 1;
  min-width: 0;
}

.message-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.message-role {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-2);
}

.message-time {
  font-size: 0.65rem;
  color: var(--text-4);
}

.message-content {
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--text);
  word-wrap: break-word;
}

.message-content p {
  margin-bottom: 12px;
}

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

/* Streaming cursor */
.message.streaming .message-content::after {
  content: '';
  display: inline-block;
  width: 8px;
  height: 16px;
  background: var(--emerald);
  margin-left: 4px;
  vertical-align: text-bottom;
  animation: blink-cursor 0.8s step-end infinite;
}

@keyframes blink-cursor {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Message Actions */
.message-actions {
  display: flex;
  gap: 4px;
  margin-top: 10px;
  opacity: 0;
  transition: opacity 0.15s;
}

.message:hover .message-actions {
  opacity: 1;
}

.message-action-btn {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-3);
  font-family: inherit;
  font-size: 0.7rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.12s;
}

.message-action-btn:hover {
  color: var(--text);
  border-color: var(--border-md);
  background: var(--surface-2);
}

/* ─── Markdown Rendering ──────────────────────────────────── */
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4 {
  margin: 20px 0 10px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.message-content h1 { font-size: 1.2rem; }
.message-content h2 { font-size: 1.1rem; }
.message-content h3 { font-size: 1rem; }

.message-content ul,
.message-content ol {
  margin: 8px 0;
  padding-left: 24px;
}

.message-content li {
  margin-bottom: 4px;
}

.message-content blockquote {
  margin: 12px 0;
  padding: 8px 16px;
  border-left: 3px solid var(--amber);
  background: rgba(226,146,74,0.05);
  border-radius: 0 6px 6px 0;
  color: var(--text-2);
}

.message-content hr {
  margin: 20px 0;
  border: none;
  border-top: 1px solid var(--border);
}

.message-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 0.82rem;
}

.message-content th,
.message-content td {
  padding: 8px 12px;
  border: 1px solid var(--border);
  text-align: left;
}

.message-content th {
  background: var(--surface-2);
  font-weight: 600;
  color: var(--text-2);
}

.message-content td {
  color: var(--text-2);
}

.message-content a {
  color: var(--emerald);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.message-content a:hover {
  color: var(--amber);
}

.message-content code {
  font-family: 'Outfit', monospace;
  font-size: 0.82em;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(232,178,122,0.08);
  color: var(--champagne, #e9c79a);
}

.message-content pre {
  margin: 12px 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #0a0705;
}

.message-content pre code {
  display: block;
  padding: 14px 16px;
  font-size: 0.8rem;
  line-height: 1.6;
  overflow-x: auto;
  background: transparent;
  color: #e8d8cc;
}

/* Code block header */
.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: rgba(18,13,9,0.6);
  border-bottom: 1px solid var(--border);
}

.code-block-lang {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.code-block-copy {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-2);
  background: var(--surface, #1c140d);
  border: 1px solid var(--border-md, rgba(232,178,122,0.20));
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.12s;
}

.code-block-copy:hover {
  border-color: var(--amber);
  color: var(--amber);
}

.code-block-copy.copied {
  border-color: var(--emerald);
  color: var(--emerald);
}

/* Inline code in lists etc */
.message-content li code,
.message-content p code,
.message-content td code {
  font-size: 0.82em;
}

/* ─── Error message ───────────────────────────────────────── */
.message.error .message-content {
  color: var(--danger, #ff6b5b);
}

/* ─── Composer ────────────────────────────────────────────── */
.composer-area {
  flex-shrink: 0;
  padding: 12px 16px 16px;
  background: linear-gradient(0deg, rgba(18,13,9,1) 60%, transparent);
}

.composer-inner {
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
}

.composer-attachments {
  display: flex;
  gap: 8px;
  padding: 8px 0;
  flex-wrap: wrap;
}

.composer-attachment {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--text-2);
}

.composer-attachment-remove {
  width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent;
  color: var(--text-3); cursor: pointer;
  border-radius: 50%;
  font-size: 0.65rem;
}

.composer-attachment-remove:hover { color: var(--danger); }

.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px;
  border-radius: 14px;
  background: var(--surface, #1c140d);
  border: 1px solid var(--border, rgba(232,178,122,0.10));
  transition: border-color 0.15s, box-shadow 0.15s;
}

.composer-row:focus-within {
  border-color: var(--border-md, rgba(232,178,122,0.20));
  box-shadow: 0 0 0 1px rgba(226,146,74,0.15);
}

.composer-textarea {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.88rem;
  line-height: 1.5;
  resize: none;
  outline: none;
  padding: 4px 4px;
  max-height: var(--composer-max-h);
  overflow-y: auto;
}

.composer-textarea::placeholder {
  color: var(--text-4);
}

.composer-textarea::-webkit-scrollbar { width: 5px; }
.composer-textarea::-webkit-scrollbar-thumb {
  background: var(--surface-3); border-radius: 3px;
}

.composer-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border: none; border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.12s;
}

.send-btn {
  background: var(--emerald);
  color: #0a0705;
}

.send-btn:hover {
  background: var(--amber, #e2924a);
  transform: translateY(-1px);
}

.send-btn:active {
  transform: translateY(0) scale(0.95);
}

.send-btn:disabled {
  background: var(--surface-3);
  color: var(--text-4);
  cursor: default;
  transform: none;
}

.stop-btn {
  background: rgba(255, 107, 91, 0.15);
  color: var(--danger);
}

.stop-btn:hover {
  background: rgba(255, 107, 91, 0.25);
}

.composer-footer {
  display: flex;
  justify-content: center;
  padding-top: 8px;
}

.composer-hint {
  font-size: 0.65rem;
  color: var(--text-4);
}

/* ─── Auth Gate ───────────────────────────────────────────── */
.auth-gate {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(14, 10, 7, 0.7);
  backdrop-filter: blur(16px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}

.auth-gate-card {
  text-align: center;
  max-width: 360px;
}

.auth-gate-icon {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border-md);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
  color: var(--champagne);
}

.auth-gate h2 {
  font-size: 1.2rem; font-weight: 700; color: var(--text);
  margin-bottom: 8px;
}

.auth-gate p {
  font-size: 0.85rem; color: var(--text-3);
  max-width: 300px; margin: 0 auto 24px; line-height: 1.55;
}

/* ─── Modals ──────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(14, 10, 7, 0.65); backdrop-filter: blur(12px);
  display: none; align-items: center; justify-content: center;
  padding: 20px;
}

.modal-backdrop.active, .modal-backdrop.open { display: flex; }
.modal-backdrop.active .modal { animation: modal-pop 0.28s cubic-bezier(0.22, 1, 0.36, 1) both; }

@keyframes modal-pop {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal {
  background: rgba(28, 20, 13, 0.9);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border-radius: 16px;
  border: 1px solid var(--border-md);
  padding: 28px 24px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 12px 40px rgba(18,13,9,0.5), 0 0 60px rgba(226,146,74,0.06);
}

.modal-wide { max-width: 540px; }

.modal-header {
  display: flex; align-items: flex-start; gap: 14px;
  margin-bottom: 20px;
}

.modal-header-icon {
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
  background: var(--emerald-bg, rgba(47,191,133,0.12));
  color: var(--emerald);
  display: flex; align-items: center; justify-content: center;
}

.modal-header-icon svg { width: 18px; height: 18px; }

.modal-header-text { flex: 1; min-width: 0; }
.modal-title {
  font-size: 1.05rem; font-weight: 700; color: var(--text);
  margin-bottom: 4px;
}
.modal-sub { font-size: 0.78rem; color: var(--text-3); line-height: 1.5; }

.modal-footer { display: flex; gap: 7px; padding-top: 16px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 0.75rem; font-weight: 600; color: var(--text-2); }

/* ─── System Prompt Editor ────────────────────────────────── */
.sp-editor {
  width: 100%;
  font-size: 0.84rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border-md);
  border-radius: 10px;
  padding: 12px;
  outline: none;
  resize: vertical;
  font-family: inherit;
  line-height: 1.6;
  transition: border-color 0.15s;
}

.sp-editor:focus { border-color: var(--amber); }

.sp-presets {
  margin-bottom: 12px;
}

.sp-presets-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-3);
  margin-bottom: 8px;
}

.sp-preset-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sp-preset-chip {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  font-family: inherit;
  font-size: 0.74rem;
  cursor: pointer;
  transition: all 0.12s;
}

.sp-preset-chip:hover {
  border-color: var(--amber);
  color: var(--text);
  background: rgba(226,146,74,0.10);
}

/* ─── Model Selector ──────────────────────────────────────── */
.model-list {
  max-height: 320px;
  overflow-y: auto;
  margin-bottom: 8px;
}

.model-list-loading,
.model-list-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-3);
  font-size: 0.82rem;
}

.model-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s;
}

.model-item:hover { background: var(--surface-2); }
.model-item.selected {
  background: rgba(226,146,74,0.10);
  border: 1px solid rgba(226,146,74,0.18);
}

.model-item-radio {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border-md);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.15s;
}

.model-item.selected .model-item-radio {
  border-color: var(--amber);
}

.model-item.selected .model-item-radio::after {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--amber);
}

.model-item-name {
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-item-owner {
  font-size: 0.65rem;
  color: var(--text-3);
  flex-shrink: 0;
}

/* ─── Buttons (reuse from styles.css) ──────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.78rem; font-weight: 500;
  border: none; border-radius: 6px; cursor: pointer;
  padding: 8px 16px; text-decoration: none; white-space: nowrap;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.15s;
}

.btn-primary { background: var(--emerald); color: #f0e4d8; }
.btn-primary:hover { background: var(--amber); color: var(--blush); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0) scale(0.98); }

.btn-ghost {
  background: transparent; color: var(--text-2);
  border: 1px solid var(--border-md);
}
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border-str); }

/* ─── Animations ──────────────────────────────────────────── */
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ─── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 100;
    transform: translateX(-100%);
  }

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

  .sidebar-backdrop.open {
    display: block;
  }

  .sidebar-close {
    display: flex;
  }

  .topbar-menu-btn {
    display: flex;
  }

  .messages-container {
    padding: 16px 12px 0;
  }

  .empty-state {
    padding: 24px 16px;
  }

  .modal {
    max-width: 100%;
    margin: 10px;
    max-height: 90vh;
    overflow-y: auto;
  }
}

@media (max-width: 480px) {
  .composer-area {
    padding: 8px 10px 12px;
  }

  .message {
    gap: 10px;
    padding: 12px 0;
  }

  .message-avatar {
    width: 26px; height: 26px;
  }

  .message-content {
    font-size: 0.85rem;
  }

  .topbar-title {
    font-size: 0.8rem;
  }
}

/* ─── Reduced motion ──────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .message { animation: none; opacity: 1; transform: none; }
  .empty-state { animation: none; }
  .modal-backdrop.active .modal { animation: none; }
  .message.streaming .message-content::after { animation: none; opacity: 0.5; }
}
