:root {
  --bg-primary: #0b0d17;
  --bg-secondary: #131728;
  --bg-card: rgba(26, 32, 56, 0.6);
  --border-color: rgba(255, 255, 255, 0.08);
  
  --accent-primary: #7c3aed;
  --accent-gradient: linear-gradient(135deg, #7c3aed 0%, #3b82f6 100%);
  --accent-hover: #6d28d9;
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;
  
  --user-bubble: #1e293b;
  --ai-bubble: rgba(124, 58, 237, 0.15);
  
  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
}

.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Sidebar */
.sidebar {
  width: 320px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* The mark is a round SVG, so no tile background or padding -- those were for
   the emoji this replaced and would have boxed the artwork in. */
.logo-icon {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 50%;
  display: block;
  object-fit: contain;
  box-shadow: 0 4px 20px rgba(255, 153, 51, 0.28);
}

.brand-text h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
}

.brand-text span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sidebar-section h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.status-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.status-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: #ef4444;
}

.status-indicator.online {
  background-color: #10b981;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.6);
}

.spec-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.spec-item {
  background: var(--bg-card);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
}

.spec-label {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.spec-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
}

.control-group {
  margin-bottom: 16px;
}

.control-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 6px;
  color: var(--text-muted);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent-primary);
  background: rgba(255, 255, 255, 0.1);
  height: 6px;
  border-radius: 3px;
  outline: none;
}

.sidebar-footer {
  margin-top: auto;
}

.btn {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius-md);
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.btn-primary {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.3);
}

.btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

/* Chat Workspace */
.chat-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
}

.chat-header {
  padding: 20px 32px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(19, 23, 40, 0.4);
}

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

.header-info p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.header-badge {
  background: rgba(124, 58, 237, 0.2);
  color: #a78bfa;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid rgba(124, 58, 237, 0.3);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.message {
  display: flex;
  gap: 16px;
  max-width: 80%;
  animation: fadeIn 0.3s ease;
}

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message.ai {
  align-self: flex-start;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  flex-shrink: 0;
}

.message.user .avatar {
  background: #3b82f6;
}

.message.ai .avatar {
  background: var(--accent-gradient);
}

.message-content {
  background: var(--ai-bubble);
  border: 1px solid rgba(124, 58, 237, 0.2);
  padding: 14px 18px;
  border-radius: 16px;
  line-height: 1.6;
  font-size: 0.95rem;
}

.message.user .message-content {
  background: var(--user-bubble);
  border: 1px solid var(--border-color);
}

.input-container {
  padding: 24px 32px;
  background: rgba(19, 23, 40, 0.6);
  border-top: 1px solid var(--border-color);
}

.chat-form {
  display: flex;
  gap: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  border-radius: 14px;
}

.chat-form:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 16px rgba(124, 58, 237, 0.2);
}

textarea {
  flex: 1;
  background: transparent;
  border: none;
  color: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  padding: 10px;
  resize: none;
  outline: none;
}

.chat-form .btn {
  width: auto;
  padding: 10px 20px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-toggle {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-toggle.active {
  background: rgba(16, 185, 129, 0.2);
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.4);
}

.btn-icon {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-icon.recording {
  background: rgba(239, 68, 68, 0.2);
  border-color: #ef4444;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  70% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

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

.quick-prompts {
  display: flex;
  gap: 8px;
  padding: 10px 32px;
  overflow-x: auto;
  background: rgba(19, 23, 40, 0.3);
  border-top: 1px solid var(--border-color);
}

.chip-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.chip-btn:hover {
  background: rgba(124, 58, 237, 0.2);
  color: #fff;
  border-color: var(--accent-primary);
  transform: translateY(-1px);
}

/* Feedback Actions */
.feedback-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.feedback-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.feedback-btn:hover {
  background: rgba(124, 58, 237, 0.2);
  color: var(--text-primary);
  border-color: var(--accent-primary);
}

.feedback-btn.rated {
  background: var(--accent-primary);
  color: #fff;
}


/* ── Code rendering in AI answers ─────────────────────────────────────────── */
.message-content .code-block {
  background: #0d1117;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 12px 14px;
  margin: 10px 0;
  overflow-x: auto;
  font-family: "Cascadia Code", "Fira Code", Consolas, monospace;
  font-size: 0.88rem;
  line-height: 1.5;
  color: #e6edf3;
  white-space: pre;
}

.message-content .code-block code {
  background: none;
  padding: 0;
  border: 0;
  color: inherit;
}

.message-content code {
  background: rgba(127, 127, 127, 0.18);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: "Cascadia Code", "Fira Code", Consolas, monospace;
  font-size: 0.9em;
}

/* ── Mobile ───────────────────────────────────────────────────────────────
   The layout was desktop-only: a fixed 320px sidebar beside the chat. On a
   phone that ate most of the screen and the chat became unusable. Below
   900px the sidebar becomes a drawer that slides in over the chat.        */

.menu-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: 10px;
  width: 40px;
  height: 40px;
  font-size: 20px;
  cursor: pointer;
  flex: 0 0 40px;
}

.sidebar-scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 40;
}

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

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

  .menu-toggle { display: block; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 84vw;
    max-width: 330px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    overflow-y: auto;
    /* The drawer is translucent on desktop; over content it needs to be solid. */
    background: var(--bg-secondary);
    backdrop-filter: none;
  }

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

  .chat-workspace { width: 100%; min-width: 0; }

  .chat-header { padding: 12px 14px; gap: 10px; }
  .chat-header h2 { font-size: 1.05rem; }
  .header-badge { display: none; }

  .chat-messages { padding: 14px 12px; }
  .message-content { max-width: 88%; }

  .chat-form { padding: 10px 12px; }

  /* Keep the composer above the on-screen keyboard and the home indicator. */
  .chat-form { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
}

@media (max-width: 420px) {
  .message-content { max-width: 94%; font-size: 0.94rem; }
  .brand-text h2 { font-size: 1.1rem; }
}

/* Fingers need a bigger target than a mouse pointer. */
@media (pointer: coarse) {
  .btn, .feedback-btn, .menu-toggle { min-height: 44px; }
}

/* ── Model picker ─────────────────────────────────────────────────────────── */
.model-picker {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 7px 12px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  max-width: 210px;
  outline: none;
}

.model-picker:focus { border-color: var(--accent-primary); }
.model-picker option { background: var(--bg-secondary); color: var(--text-main); }
.model-picker option:disabled { color: var(--text-dim); }
.model-picker:disabled { opacity: 0.5; cursor: wait; }

@media (max-width: 900px) {
  /* Keep the picker -- switching brains matters more on a phone than the
     voice toggle, which is why that one is what gets dropped. */
  .model-picker { max-width: 132px; font-size: 0.72rem; padding: 6px 8px; }
  .btn-toggle { display: none; }
}
