/* Moe — Modern AI for Electrical Distributors
   Theme system: dark (default) / light via [data-theme="light"] on <html> */

/* ─── Dark theme (default) — warm neutral with #1f1f1e base ─── */
:root {
  --bg: #1f1f1e;
  --surface: #2a2a29;
  --surface-hover: #343433;
  --border: #3d3d3c;
  --text: #e8e8e6;
  --text-dim: #a0a09e;
  --text-muted: #6b6b69;
  --mayer: #2563eb;
  --mayer-dark: #1d4ed8;
  --mayer-deep: #1e3a8a;
  --mayer-light: #60a5fa;
  --mayer-glow: rgba(37,99,235,0.15);
  --user-bubble: #1e3a8a;
  --user-bubble-end: #2563eb;
  --user-text: #ffffff;
  --bot-bubble: #2a2a29;
  --bot-text: #e8e8e6;
  --haiku: #22c55e;
  --sonnet: #f59e0b;
  --opus: #a855f7;
  --opus-thinking: #ec4899;
  --error: #ef4444;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.25);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.35);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.45);
  --glass: rgba(31,31,30,0.92);
  --glass-border: rgba(61,61,60,0.6);
  --code-bg: #181817;
  --pre-bg: #181817;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ─── Light theme ─── */
[data-theme="light"] {
  --bg: #ffffff;
  --surface: #f4f5f7;
  --surface-hover: #ecedf0;
  --border: #dde0e7;
  --text: #1a1a2e;
  --text-dim: #5c6070;
  --text-muted: #9098a8;
  --mayer-glow: rgba(37,99,235,0.10);
  --user-bubble: #2563eb;
  --user-bubble-end: #3b82f6;
  --user-text: #ffffff;
  --bot-bubble: #f4f5f7;
  --bot-text: #1a1a2e;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.10);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --glass: rgba(255,255,255,0.92);
  --glass-border: rgba(221,224,231,0.8);
  --code-bg: #eef2f7;
  --pre-bg: #1e293b;
}

/* Light theme overrides for specific elements */
[data-theme="light"] .icon-btn:hover { background: rgba(0,0,0,0.06); }
[data-theme="light"] .msg.user { box-shadow: 0 2px 8px rgba(37,99,235,0.15); }
[data-theme="light"] .msg.assistant { box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
[data-theme="light"] .msg.assistant .msg-content strong { color: #1e3a8a; }
[data-theme="light"] .msg.assistant .msg-content code {
  background: #eef2f7; color: var(--mayer-dark); border-color: #dde0e7;
}
[data-theme="light"] .msg.assistant .msg-content a { color: var(--mayer-dark); }
[data-theme="light"] .drawing-card-preview { background: #f8f9fb; }
[data-theme="light"] aside#sidebar { background: #f8f9fb; }
[data-theme="light"] .sidebar-header { background: #f0f1f4; }
[data-theme="light"] .conv-item.active { background: #e8ebf0; }
[data-theme="light"] .doc-markdown strong { color: #1e3a8a; }
[data-theme="light"] .doc-markdown h1, [data-theme="light"] .doc-markdown h2 { color: #1e3a8a; }
[data-theme="light"] .doc-markdown code { background: #eef2f7; color: var(--mayer-dark); border-color: #dde0e7; }
[data-theme="light"] main#chatArea {
  background: #ffffff;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  height: 100vh;
  height: 100dvh;
}

/* ================================================================
   Custom scrollbar (desktop)
   ================================================================ */

@media (min-width: 768px) {
  ::-webkit-scrollbar { width: 6px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 3px;
    transition: background 0.3s;
  }
  *:hover::-webkit-scrollbar-thumb { background: rgba(139, 144, 168, 0.2); }
  ::-webkit-scrollbar-thumb:hover { background: rgba(139, 144, 168, 0.35); }
  * { scrollbar-width: thin; scrollbar-color: transparent transparent; }
  *:hover { scrollbar-color: rgba(139, 144, 168, 0.2) transparent; }
}

/* ================================================================
   Animations
   ================================================================ */

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes shimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}
@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}
@keyframes blink {
  50% { opacity: 0; }
}
@keyframes breathe {
  0%, 100% { box-shadow: 0 4px 20px rgba(37,99,235,0.25); }
  50% { box-shadow: 0 4px 30px rgba(37,99,235,0.45); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-30px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes orbGlow {
  0%, 100% { opacity: 0.3; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.1); }
}
@keyframes shimmerText {
  0% { background-position: 100% 50%; }
  50% { background-position: 0% 50%; }
  100% { background-position: 100% 50%; }
}
@keyframes stopPulse {
  0%, 100% { box-shadow: 0 2px 10px rgba(239, 68, 68, 0.3); }
  50% { box-shadow: 0 2px 16px rgba(239, 68, 68, 0.5); }
}

/* ================================================================
   Top bar (mobile only)
   ================================================================ */

header#topBar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  padding-top: var(--safe-top);
  background: linear-gradient(135deg, var(--mayer-deep) 0%, #0f1a3a 100%);
  color: white;
  display: none;
  align-items: center;
  justify-content: space-between;
  padding-left: 14px;
  padding-right: 14px;
  z-index: 100;
  box-shadow: 0 2px 16px rgba(0,0,0,0.4);
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.icon-btn {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 8px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.15s var(--ease-spring);
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover { background: rgba(255,255,255,0.1); }
.icon-btn:active { transform: scale(0.9); }

/* ================================================================
   Logo icon
   ================================================================ */

.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--mayer), var(--mayer-deep));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  color: white;
  box-shadow: 0 2px 12px rgba(37,99,235,0.3);
  flex-shrink: 0;
}

.logo-icon-sm {
  width: 30px;
  height: 30px;
  font-size: 15px;
  border-radius: 8px;
}

/* ================================================================
   Sidebar
   ================================================================ */

aside#sidebar {
  position: fixed;
  top: 0;
  left: -320px;
  bottom: 0;
  width: 280px;
  background: var(--pre-bg, #181817);
  z-index: 200;
  transition: left 0.35s var(--ease-out);
  display: flex;
  flex-direction: column;
  box-shadow: 6px 0 30px rgba(0,0,0,0.4);
}
aside#sidebar.open { left: 0; }

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

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-text {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
}

.sidebar-header .icon-btn {
  color: var(--text-muted);
  font-size: 24px;
  line-height: 1;
}

.collapse-btn svg { transition: transform 0.25s var(--ease-out); }

/* Sidebar tabs */
.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 8px;
}

.sidebar-tab {
  flex: 1;
  padding: 10px 8px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.sidebar-tab.active {
  color: var(--mayer-light);
  border-bottom-color: var(--mayer);
}
.sidebar-tab:hover { color: var(--text); }

.sidebar-panel {
  flex: 1;
  overflow-y: auto;
}

/* Conversation list */
.conversation-list { padding: 8px; }

.conv-item {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-bottom: 4px;
  transition: all 0.2s var(--ease-out);
  border-left: 3px solid transparent;
  background: rgba(42,42,41,0.5);
  border: 1px solid transparent;
  -webkit-tap-highlight-color: transparent;
}
.conv-item:hover {
  background: var(--surface-hover);
  border-color: var(--border);
  transform: translateX(2px);
}
.conv-item:active { transform: scale(0.98); }
.conv-item.active {
  background: var(--surface);
  border-left: 3px solid var(--mayer);
  box-shadow: 0 1px 6px rgba(0,0,0,0.2);
}

.conv-item .preview {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-item .meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  display: flex;
  gap: 6px;
  align-items: center;
}

.conv-item .meta-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--mayer);
  flex-shrink: 0;
}

/* Memory panel */
.memory-list { padding: 6px 8px; }

.memory-item {
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 4px;
  background: rgba(42,42,41,0.6);
  border: 1px solid var(--border);
  position: relative;
  animation: slideUp 0.2s var(--ease-out);
}

.memory-item-cat {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--mayer-light);
  margin-bottom: 2px;
}

.memory-item-key {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.memory-item-val {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
  line-height: 1.4;
}

.memory-item-del {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.memory-item:hover .memory-item-del { opacity: 1; }
.memory-item-del:hover { color: var(--error); }

.memory-empty {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 13px;
}

/* Sidebar footer */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-new-chat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 9px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-dim);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}
.sidebar-new-chat:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--mayer);
}

.sidebar-profile {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}

.sidebar-profile-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--mayer), var(--mayer-deep));
  color: white;
  border: none;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
}
.sidebar-profile-btn:hover { transform: scale(1.08); }

.sidebar-profile-name {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-profile-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.sidebar-profile-actions .icon-btn {
  padding: 5px;
  color: var(--text-muted);
}
.sidebar-profile-actions .icon-btn:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.logout-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  transition: color 0.15s;
}
.logout-link:hover { color: var(--mayer-light); }

/* Overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  z-index: 150;
  display: none;
  transition: background 0.35s, backdrop-filter 0.35s;
}
.overlay.show {
  display: block;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

/* ================================================================
   Chat area
   ================================================================ */

main#chatArea {
  flex: 1;
  position: relative;
  overflow-y: auto;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  background:
    radial-gradient(ellipse at 50% 20%, rgba(37,99,235,0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(30,58,138,0.02) 0%, transparent 50%),
    var(--bg);
  padding-bottom: 140px;
}

.messages {
  padding: 16px 12px;
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 100%;
  position: relative;
  z-index: 1;
}

/* Hint browser to optimize streaming repaints */
.msg.assistant.typing .msg-content {
  will-change: contents;
}

/* ================================================================
   Welcome screen
   ================================================================ */

.welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 24px 24px;
  animation: slideUp 0.6s var(--ease-out);
  min-height: 60vh;
}

.welcome-logo-icon {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--mayer), var(--mayer-deep));
  background-size: 200% 200%;
  animation: shimmer 4s ease-in-out infinite, breathe 3s ease-in-out infinite;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 800;
  color: white;
  margin-bottom: 16px;
  box-shadow: 0 4px 24px rgba(37,99,235,0.35);
}

.welcome-title {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--text);
}

.welcome-subtitle {
  font-size: 15px;
  line-height: 1.65;
  max-width: 480px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.welcome-disclaimer {
  font-size: 11px;
  color: var(--text-muted);
  max-width: 400px;
  margin-bottom: 24px;
  line-height: 1.4;
  animation: slideUp 0.8s var(--ease-out) 0.15s both;
}

.welcome-examples {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 520px;
  animation: slideUp 0.8s var(--ease-out) 0.3s both;
}

.example-btn {
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  line-height: 1.4;
  font-family: inherit;
  transition: all 0.2s var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
.example-btn:hover {
  border-color: var(--mayer);
  color: var(--text);
  background: var(--surface-hover);
  box-shadow: 0 0 0 1px var(--mayer-glow), 0 2px 10px rgba(37,99,235,0.1);
  transform: translateY(-1px);
}
.example-btn:active { transform: scale(0.98); }

/* ================================================================
   Message bubbles
   ================================================================ */

.msg {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 15px;
  line-height: 1.55;
  word-wrap: break-word;
  overflow-wrap: break-word;
  overflow: visible;
  position: relative;
  will-change: transform, opacity;
}

.msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--user-bubble) 0%, var(--user-bubble-end) 100%);
  color: var(--user-text);
  border-bottom-right-radius: 6px;
  box-shadow: 0 2px 10px rgba(37,99,235,0.25);
  animation: slideInRight 0.3s var(--ease-out);
}

.msg.assistant {
  align-self: flex-start;
  background: var(--bot-bubble);
  color: var(--bot-text);
  border-bottom-left-radius: 6px;
  border-left: 3px solid var(--mayer);
  padding-left: 18px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.2), 0 1px 2px rgba(0,0,0,0.1);
  animation: slideInLeft 0.3s var(--ease-out);
}

/* Typing cursor */
.msg.typing .msg-content::after {
  content: "";
  display: inline-block;
  width: 2.5px;
  height: 1.1em;
  background: var(--mayer);
  margin-left: 1px;
  animation: blink 0.5s step-end infinite;
  vertical-align: text-bottom;
  border-radius: 1px;
}

/* ================================================================
   Waiting indicator — shimmer orbs + rotating word
   ================================================================ */

.waiting-dots {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: var(--bot-bubble);
  border-radius: var(--radius);
  border-bottom-left-radius: 6px;
  border-left: 3px solid var(--mayer);
  box-shadow: 0 1px 6px rgba(0,0,0,0.2);
  animation: slideInLeft 0.25s var(--ease-out);
}

.waiting-dots .orb-group {
  display: flex;
  gap: 4px;
  align-items: center;
}

.waiting-dots span.orb {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--mayer);
  animation: orbGlow 2s ease-in-out infinite;
}
.waiting-dots span.orb:nth-child(2) { animation-delay: 0.3s; }
.waiting-dots span.orb:nth-child(3) { animation-delay: 0.6s; }

.waiting-word {
  font-size: 13px;
  font-weight: 500;
  background: linear-gradient(90deg, var(--text-dim), var(--mayer), var(--text-dim));
  background-size: 200% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmerText 3s ease-in-out infinite;
  transition: opacity 0.3s;
}

/* ================================================================
   Status area — thinking + tools
   ================================================================ */

.status-area {
  align-self: flex-start;
  width: 100%;
  max-width: 85%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 4px 0;
  animation: slideUp 0.25s var(--ease-out);
}

/* Thinking block */
.thinking-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--mayer);
  border-radius: var(--radius-sm);
  overflow: hidden;
  font-size: 13px;
  box-shadow: var(--shadow-sm);
  animation: slideUp 0.25s var(--ease-out);
}

.thinking-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  cursor: pointer;
  user-select: none;
  color: var(--text-dim);
  transition: background 0.2s;
}
.thinking-header:hover { background: var(--surface-hover); }

.thinking-icon { display: flex; align-items: center; }

.thinking-icon .dot {
  width: 6px;
  height: 6px;
  background: var(--opus-thinking);
  border-radius: 50%;
  animation: pulse 1s infinite;
}

.thinking-icon .check {
  color: var(--haiku);
  font-size: 14px;
  font-weight: bold;
}

.thinking-label {
  flex: 1;
  font-weight: 500;
}

.thinking-chevron {
  font-size: 10px;
  transition: transform 0.3s var(--ease-out);
}

.thinking-block.expanded .thinking-chevron {
  transform: rotate(180deg);
}

.thinking-content {
  max-height: 0;
  overflow: hidden;
  padding: 0 12px;
  color: var(--text-muted);
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  transition: max-height 0.4s var(--ease-out), padding 0.4s var(--ease-out);
}

.thinking-block.expanded .thinking-content {
  max-height: 300px;
  overflow-y: auto;
  padding: 0 12px 10px;
}

/* Tool line */
/* Compact tool status (single line instead of stacked blocks) */
.tool-status-compact {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-muted);
  animation: fadeIn 0.2s;
}
.tool-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--mayer-light);
  animation: pulse 1s infinite;
  flex-shrink: 0;
}
.tool-status-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  font-size: 13px;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  animation: slideUp 0.2s var(--ease-out);
  box-shadow: var(--shadow-sm);
  transition: all 0.25s var(--ease-out);
}

.tool-line[data-active="false"] {
  opacity: 0.75;
}

.tool-line .dot {
  width: 6px;
  height: 6px;
  background: var(--mayer);
  border-radius: 50%;
  animation: pulse 1s infinite;
  flex-shrink: 0;
}

.tool-line .check {
  color: var(--haiku);
  font-size: 14px;
  font-weight: bold;
  flex-shrink: 0;
}

.tool-label { flex: 1; }

.tool-progress-size {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 400;
  font-family: 'SF Mono', Monaco, Consolas, monospace;
}

/* Tool progress bar — animated indeterminate */
.tool-progress-bar {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--mayer);
  animation: toolSpin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes toolSpin {
  to { transform: rotate(360deg); }
}

.tool-line[data-active="false"] .tool-progress-bar {
  display: none;
}

/* Library search icon — bouncing magnifying glass */
.tool-search-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  animation: searchBounce 1s ease-in-out infinite;
}

@keyframes searchBounce {
  0%, 100% { transform: translateX(0) rotate(0deg); }
  25% { transform: translateX(3px) rotate(5deg); }
  75% { transform: translateX(-3px) rotate(-5deg); }
}

.tool-line[data-active="false"] .tool-search-icon {
  animation: none;
}

/* Collapsed tools summary toggle */
.tools-collapsed-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s;
  user-select: none;
}
.tools-collapsed-toggle:hover {
  background: var(--surface-hover);
  color: var(--text-dim);
}
.tools-collapsed-toggle .check { color: var(--haiku); }
.tools-expand-arrow {
  font-size: 10px;
  margin-left: 4px;
  opacity: 0.5;
}
.tools-collapsed-detail {
  margin-top: 4px;
  animation: fadeIn 0.2s;
}

/* Quick reply suggestion buttons (after Moe answers) */
.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  animation: fadeIn 0.3s var(--ease-out);
}

.quick-reply-btn {
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: none;
  color: var(--mayer-light);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  white-space: nowrap;
}
.quick-reply-btn:hover {
  background: var(--mayer-glow);
  border-color: var(--mayer);
}
.quick-reply-btn:active {
  transform: scale(0.95);
}

@media (max-width: 767px) {
  .quick-reply-btn { font-size: 14px; padding: 9px 16px; }
}

/* Source citation card */
.source-card {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 12px;
  background: rgba(34,197,94,0.06);
  border: 1px solid rgba(34,197,94,0.15);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-dim);
  animation: fadeIn 0.2s;
}
.source-card-link {
  color: var(--haiku);
  text-decoration: none;
  font-weight: 500;
}
.source-card-link:hover { text-decoration: underline; }

/* PDF download card */
.pdf-card {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  animation: slideUp 0.3s var(--ease-out);
}
.pdf-card-icon {
  color: var(--error);
  flex-shrink: 0;
}
.pdf-card-info { flex: 1; min-width: 0; }
.pdf-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.pdf-card-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.pdf-card-download {
  padding: 8px 16px;
  background: var(--mayer);
  color: white;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  flex-shrink: 0;
  transition: background 0.15s;
}
.pdf-card-download:hover { background: var(--mayer-dark); }

/* Smoother typing — content fades in */
.msg.assistant.typing .msg-content {
  will-change: contents;
}

/* ================================================================
   Library search results panel
   ================================================================ */

.library-results {
  margin: 6px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  animation: slideUp 0.3s var(--ease-out);
  background: rgba(42,42,41,0.6);
}

.library-results-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.library-results-header:hover {
  background: var(--surface-hover);
}

.library-icon {
  display: flex;
  gap: 4px;
  align-items: center;
  opacity: 0.7;
}

.library-results-title { flex: 1; }

.library-chevron {
  font-size: 10px;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.library-results.expanded .library-chevron {
  transform: rotate(180deg);
}

.library-results-list {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s var(--ease-out);
}

.library-results.expanded .library-results-list {
  max-height: 600px;
  overflow-y: auto;
}

.library-result-item {
  border-top: 1px solid var(--border);
}

.library-result-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.library-result-link:hover {
  background: var(--surface-hover);
  color: var(--mayer-light);
}

.library-result-link svg {
  flex-shrink: 0;
}

.library-result-info {
  flex: 1;
  min-width: 0;
}

.library-result-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.library-result-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.library-result-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  align-items: center;
}

.lib-action-pill {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 12px;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.view-pill {
  background: var(--mayer-glow);
  color: var(--mayer-light);
  border: 1px solid rgba(37, 99, 235, 0.25);
}

.view-pill:hover {
  background: rgba(37, 99, 235, 0.25);
}

.source-pill {
  background: rgba(34, 197, 94, 0.1);
  color: var(--haiku);
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.source-pill:hover {
  background: rgba(34, 197, 94, 0.2);
}

/* ================================================================
   Drawing cards (inline in chat)
   ================================================================ */

.drawing-card {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #ffffff;
  animation: slideUp 0.3s var(--ease-out);
}

.drawing-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
}

.drawing-card-header svg { flex-shrink: 0; opacity: 0.6; }
.drawing-card-header span { flex: 1; }

.drawing-card-actions {
  display: flex;
  gap: 4px;
}

.drawing-action-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  display: flex;
  align-items: center;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.drawing-action-btn:hover {
  border-color: var(--mayer);
  color: var(--mayer-light);
}

.drawing-card-preview {
  padding: 8px;
  background: #ffffff;
  text-align: center;
}

.drawing-card-preview img {
  max-width: 100%;
  height: auto;
  max-height: 400px;
  border-radius: 4px;
}

/* ================================================================
   Cross-Reference Comparison Card
   ================================================================ */

.comparison-card {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
  animation: slideUp 0.3s var(--ease-out);
}

.comparison-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
}

.comparison-card-header svg { flex-shrink: 0; opacity: 0.6; }
.comparison-card-header > span:nth-child(2) { flex: 1; }

.xref-confidence {
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
  flex-shrink: 0;
}

.conf-high { background: rgba(34,197,94,0.15); color: var(--haiku); }
.conf-med { background: rgba(245,158,11,0.15); color: var(--sonnet); }
.conf-low { background: rgba(239,68,68,0.15); color: var(--error); }

.xref-warning {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(245,158,11,0.1);
  color: var(--sonnet);
  font-size: 12px;
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  line-height: 1.4;
}

.xref-warning svg { flex-shrink: 0; stroke: var(--sonnet); }

[data-theme="light"] .xref-warning { background: #fef3c7; color: #92400e; }
[data-theme="light"] .xref-warning svg { stroke: #92400e; }

/* Brand color divider bar */
.xref-brand-bar {
  display: grid;
  grid-template-columns: 120px 1fr 1fr;
  overflow: hidden;
}

.xref-brand-cell {
  padding: 9px 12px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.xref-brand-label {
  background: transparent !important;
}

@media (max-width: 480px) {
  .xref-brand-bar { grid-template-columns: 80px 1fr 1fr; }
  .xref-brand-cell { font-size: 10px; padding: 7px 6px; }
}

.comparison-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.comparison-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.comparison-table th {
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  background: rgba(0,0,0,0.1);
}

.comparison-table th.se-col {
  color: var(--mayer-light);
}

.comparison-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.comparison-table td.spec-label {
  font-weight: 500;
  color: var(--text-dim);
  white-space: nowrap;
  width: 120px;
}

.comparison-table td.se-col-cell {
  color: #3DCD58;
  font-weight: 500;
}

/* Column widths + background tints */
.comparison-table .col-spec { width: 120px; }
.comparison-table .col-se { background: rgba(61,205,88,0.04); }
.comparison-table .col-comp { background: rgba(255,255,255,0.02); }

@media (max-width: 480px) {
  .comparison-table .col-spec { width: 80px; }
}

.se-advantages {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}

.se-adv-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: block;
}

.se-advantage-badge {
  display: inline-block;
  padding: 4px 10px;
  margin: 0 6px 6px 0;
  background: rgba(61,205,88,0.1);
  color: #3DCD58;
  border: 1px solid rgba(61,205,88,0.2);
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.3;
}

[data-theme="light"] .se-advantage-badge {
  background: #dbeafe;
  color: #1e40af;
  border-color: #bfdbfe;
}

[data-theme="light"] .comparison-table .col-comp { background: rgba(0,0,0,0.02); }
[data-theme="light"] .comparison-table .col-se { background: rgba(61,205,88,0.06); }
[data-theme="light"] .comparison-table td.se-col-cell { color: #009530; }

.comparison-card-footer {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

.battle-card-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  background: var(--mayer);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.battle-card-btn:hover {
  background: var(--mayer-dark);
  box-shadow: 0 2px 8px rgba(37,99,235,0.3);
}

.battle-card-btn svg { flex-shrink: 0; }

@media (max-width: 480px) {
  .comparison-table { font-size: 12px; }
  .comparison-table td.spec-label { width: auto; }
  .se-advantage-badge { font-size: 10px; padding: 2px 8px; }
}

/* ================================================================
   Drawing fullscreen viewer
   ================================================================ */

.drawing-viewer {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #ffffff;
  z-index: 300;
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.2s ease-out;
}

.drawing-viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  flex-shrink: 0;
}

.drawing-viewer-header span { font-weight: 600; font-size: 15px; }

.drawing-viewer-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.drawing-viewer-body {
  flex: 1;
  overflow: auto;
  padding: 16px;
  touch-action: pan-x pan-y pinch-zoom;
  -webkit-overflow-scrolling: touch;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.drawing-viewer-body img {
  max-width: 100%;
  height: auto;
}

/* ================================================================
   Markdown in assistant messages (dark theme)
   ================================================================ */

.msg.assistant .msg-content strong { font-weight: 700; color: #ffffff; }
.msg.assistant .msg-content em { font-style: italic; color: var(--text-dim); }

/* Inline code */
.msg.assistant .msg-content code {
  background: rgba(37,99,235,0.12);
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 12px;
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  border: 1px solid rgba(37,99,235,0.2);
  color: var(--mayer-light);
}

/* Code blocks */
.msg.assistant .msg-content pre {
  background: #080c18;
  color: #e2e8f0;
  padding: 14px 16px;
  border-radius: 10px;
  overflow-x: auto;
  margin: 10px 0;
  font-size: 12px;
  line-height: 1.5;
  border: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
}

.msg.assistant .msg-content pre code {
  background: transparent;
  border: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

/* Lists */
.msg.assistant .msg-content ul,
.msg.assistant .msg-content ol {
  padding-left: 1.3em;
  margin: 8px 0;
  list-style-position: outside;
}
.msg.assistant .msg-content ul { list-style-type: disc; }
.msg.assistant .msg-content ol { list-style-type: decimal; }
.msg.assistant .msg-content li {
  margin: 4px 0;
  line-height: 1.5;
}
.msg.assistant .msg-content li::marker { color: var(--mayer); }

/* Links */
.msg.assistant .msg-content a {
  color: var(--mayer-light);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: rgba(96,165,250,0.4);
}
.msg.assistant .msg-content a:hover {
  text-decoration-color: var(--mayer-light);
}

/* SE product links */
.se-product-link {
  color: #3DCD58 !important;
  text-decoration: none !important;
  font-weight: 600;
  border-bottom: 1px dashed rgba(61,205,88,0.4);
  transition: all 0.15s;
}
.se-product-link:hover {
  border-bottom-color: #3DCD58;
  border-bottom-style: solid;
}
[data-theme="light"] .se-product-link {
  color: #009e3c !important;
  border-bottom-color: rgba(0,158,60,0.3);
}

/* Tables */
.msg.assistant .msg-content table {
  border-collapse: separate;
  border-spacing: 0;
  margin: 10px 0;
  font-size: 12px;
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.msg.assistant .msg-content th {
  background: var(--mayer-deep);
  color: white;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 8px 10px;
  text-align: left;
  border: none;
  border-bottom: 2px solid var(--mayer-deep);
}

.msg.assistant .msg-content td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid rgba(35,42,80,0.4);
  color: var(--text);
}
.msg.assistant .msg-content td:last-child { border-right: none; }
.msg.assistant .msg-content tr:last-child td { border-bottom: none; }
.msg.assistant .msg-content tr:hover td { background: var(--surface-hover); }

/* Blockquotes */
.msg.assistant .msg-content blockquote {
  border-left: 3px solid var(--mayer);
  padding: 6px 12px;
  margin: 8px 0;
  color: var(--text-dim);
  font-style: italic;
  background: rgba(37,99,235,0.05);
  border-radius: 0 6px 6px 0;
}

/* Headers in messages */
.msg.assistant .msg-content h2,
.msg.assistant .msg-content h3 {
  font-weight: 700;
  color: #ffffff;
  margin: 12px 0 6px 0;
}
.msg.assistant .msg-content h2 { font-size: 1.05em; }
.msg.assistant .msg-content h3 { font-size: 1em; }

/* Horizontal rules */
.msg.assistant .msg-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 12px 0;
}

/* ================================================================
   Metadata — tier badge, timing, feedback
   ================================================================ */

.msg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.tier-badge {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.tier-badge.haiku { background: rgba(34,197,94,0.12); color: var(--haiku); }
.tier-badge.sonnet { background: rgba(245,158,11,0.12); color: var(--sonnet); }
.tier-badge.opus { background: rgba(168,85,247,0.12); color: var(--opus); }
.tier-badge.opus-thinking { background: rgba(236,72,153,0.12); color: var(--opus-thinking); }

.feedback-btns { display: flex; gap: 4px; }

.feedback-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.feedback-btn:hover { background: var(--surface-hover); color: var(--text); }
.feedback-btn.active { color: var(--mayer-light); }
.tts-btn { color: var(--text-muted); }
.tts-btn:hover { color: var(--mayer-light); }
.tts-btn.tts-active {
  color: var(--mayer-light);
  animation: pulse 1.5s infinite;
}

/* ================================================================
   Quick actions
   ================================================================ */

.quick-actions {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 74px;
  padding: 8px 12px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 900px;
  margin: 0 auto;
  z-index: 40;
}
.quick-actions::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  padding: 8px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  font-size: 13px;
  font-weight: 500;
  color: var(--mayer-light);
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: all 0.25s var(--ease-out);
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}
.chip:hover {
  border-color: var(--mayer);
  box-shadow: 0 3px 12px rgba(37,99,235,0.2);
  transform: translateY(-2px);
  color: white;
}
.chip:active { transform: translateY(0) scale(0.97); }

/* ================================================================
   Input area — glass effect
   ================================================================ */

footer#inputArea {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border-top: 1px solid var(--glass-border);
  padding: 10px 12px;
  padding-bottom: calc(10px + var(--safe-bottom));
  z-index: 50;
}

.routing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 6px 6px;
  max-width: 900px;
  margin: 0 auto;
  font-size: 12px;
  color: var(--text-dim);
  animation: fadeIn 0.2s;
}

/* Voice bar — recording indicator */
.voice-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  max-width: 900px;
  margin: 0 auto 6px;
  background: rgba(239, 68, 68, 0.1);
  border: 1.5px solid rgba(239, 68, 68, 0.25);
  border-radius: 14px;
  animation: fadeIn 0.2s var(--ease-out);
}

.voice-pulse {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ef4444;
  animation: voicePulse 1.2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes voicePulse {
  0%, 100% { opacity: 0.4; transform: scale(0.8); box-shadow: 0 0 0 0 rgba(239,68,68,0.4); }
  50% { opacity: 1; transform: scale(1); box-shadow: 0 0 0 8px rgba(239,68,68,0); }
}

.voice-status {
  font-size: 16px;
  color: #ef4444;
  font-weight: 600;
  flex: 1;
}

.voice-mode {
  font-size: 13px;
  color: var(--text-muted);
  background: var(--surface);
  padding: 4px 10px;
  border-radius: 8px;
}

/* Mic button */
.mic-btn {
  background: var(--surface);
  border: 2px solid var(--border);
  color: var(--text-dim);
  border-radius: 50%;
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s var(--ease-spring);
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
.mic-btn svg { width: 22px; height: 22px; }
.mic-btn:hover { border-color: var(--mayer); color: var(--mayer-light); background: var(--mayer-glow); }
.mic-btn:active { transform: scale(0.9); }

/* Recording state */
.mic-btn.recording {
  background: rgba(239, 68, 68, 0.15);
  border-color: #ef4444;
  color: #ef4444;
  animation: micRecording 1.5s ease-in-out infinite;
}

@keyframes micRecording {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.3); }
  50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

/* Push-to-talk active state */
.mic-btn.ptt-active {
  background: rgba(37, 99, 235, 0.15);
  border-color: var(--mayer);
  color: var(--mayer-light);
  transform: scale(1.1);
  box-shadow: 0 0 0 4px var(--mayer-glow);
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 900px;
  margin: 0 auto;
}

#msgInput {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: 22px;
  padding: 10px 18px;
  font-size: 16px;
  line-height: 1.4;
  resize: none;
  outline: none;
  max-height: 120px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.25s, box-shadow 0.25s;
}
#msgInput::placeholder { color: var(--text-muted); }

.input-disclaimer {
  text-align: center;
  font-size: 10px;
  color: var(--text-muted);
  padding-top: 4px;
  opacity: 0.6;
}

/* Guest welcome popup */
.guest-popup {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.3s var(--ease-out);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.guest-popup.closing {
  opacity: 0;
  transition: opacity 0.3s;
}

.guest-popup-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px 32px;
  max-width: 380px;
  width: 90%;
  text-align: center;
  animation: scaleIn 0.3s var(--ease-out);
}

.guest-popup-icon {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--mayer), var(--mayer-deep));
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 24px;
  color: white;
  margin-bottom: 16px;
  box-shadow: 0 4px 20px rgba(37,99,235,0.3);
}

.guest-popup-card h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 10px;
}

.guest-popup-card p {
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 20px;
}

.guest-popup-card strong { color: var(--mayer-light); }

.guest-popup-btn {
  display: block;
  width: 100%;
  padding: 12px;
  background: var(--mayer);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: 0 2px 12px rgba(37,99,235,0.3);
}

.guest-popup-btn:hover { background: var(--mayer-dark); transform: translateY(-1px); }

.guest-popup-link {
  display: block;
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 13px;
  text-decoration: none;
}

.guest-popup-link:hover { color: var(--mayer-light); text-decoration: underline; }

/* Guest message counter (top-right pill) */
.guest-counter {
  position: fixed;
  top: 12px;
  right: 16px;
  z-index: 55;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-dim);
  box-shadow: var(--shadow-sm);
  transition: all 0.3s var(--ease-out);
}

.gc-num {
  font-weight: 700;
  font-size: 14px;
  color: var(--mayer-light);
  min-width: 14px;
  text-align: center;
}

.gc-label { font-weight: 500; }

.gc-low .gc-num { color: var(--orange); }
.gc-low { border-color: rgba(245,158,11,0.3); }

.guest-counter.expired {
  border-color: rgba(239,68,68,0.3);
  background: rgba(239,68,68,0.08);
}

.gc-num.gc-expired { color: var(--error); }

.gc-signup {
  color: var(--mayer);
  font-weight: 600;
  text-decoration: none;
  font-size: 12px;
}

.gc-signup:hover { text-decoration: underline; }

@media (max-width: 767px) {
  .guest-counter { top: 10px; right: 10px; padding: 4px 10px; font-size: 11px; }
  .gc-num { font-size: 13px; }
  .guest-popup-card { padding: 28px 24px; }
}
/* ─── Camera/attach button ─── */
.attach-circle {
  background: none;
  border: none;
  color: var(--text-muted);
  width: 42px;
  height: 42px;
  min-width: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  border-radius: 50%;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}
.attach-circle:hover { color: var(--text-dim); }
.attach-circle:active { transform: scale(0.9); }

/* Attach bottom sheet */
.attach-sheet-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.attach-sheet-overlay.open { align-items: flex-end; animation: fadeIn 0.15s; }

.attach-sheet {
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 8px 20px 28px;
  padding-bottom: calc(28px + var(--safe-bottom));
  animation: slideUp 0.25s var(--ease-out);
}

.attach-sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 16px;
}

.attach-sheet-options {
  display: flex;
  justify-content: center;
  gap: 32px;
}

.attach-sheet-option {
  -webkit-appearance: none;
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  padding: 8px;
}
.attach-sheet-option:active { transform: scale(0.92); }

.attach-sheet-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
}
.attach-sheet-option:hover .attach-sheet-icon { transform: scale(1.05); }

/* ─── Attachment preview strip ─── */
.attach-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 900px;
  margin: 0 auto 6px;
  padding: 0 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.attach-preview::-webkit-scrollbar { display: none; }

.attach-thumb {
  position: relative;
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  border-radius: 10px;
  overflow: hidden;
  border: 1.5px solid var(--border);
  background: var(--surface);
  animation: scaleIn 0.2s var(--ease-spring);
}

.attach-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.attach-thumb-pdf {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 10px;
  font-weight: 700;
  color: var(--error);
  text-transform: uppercase;
  background: var(--surface);
}

.attach-thumb-remove {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--error);
  color: white;
  border: 2px solid var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  font-weight: 700;
  transition: transform 0.15s;
  z-index: 1;
}
.attach-thumb-remove:hover { transform: scale(1.15); }

/* Image in user bubble */
.msg-image {
  max-width: 280px;
  max-height: 200px;
  border-radius: 12px;
  margin-bottom: 6px;
  object-fit: cover;
  cursor: pointer;
  transition: transform 0.15s;
}
.msg-image:hover { transform: scale(1.02); }

/* Full-size image viewer overlay */
.image-viewer {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  cursor: zoom-out;
  animation: fadeIn 0.2s;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.image-viewer img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}

#msgInput:focus {
  border-color: var(--mayer);
  box-shadow: 0 0 0 3px var(--mayer-glow);
}

.send-btn {
  background: linear-gradient(135deg, var(--mayer) 0%, var(--mayer-dark) 100%);
  color: white;
  border: none;
  border-radius: 50%;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(37,99,235,0.35);
  transition: all 0.2s var(--ease-spring);
  -webkit-tap-highlight-color: transparent;
}
.send-btn:hover { transform: scale(1.08); box-shadow: 0 4px 16px rgba(37,99,235,0.4); }
.send-btn:active { transform: scale(0.92); }
.send-btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; box-shadow: none; }

.send-btn.ready {
  box-shadow: 0 2px 10px rgba(37,99,235,0.35), 0 0 20px rgba(37,99,235,0.2);
}

/* Stop mode — red square */
.send-btn.stop-mode {
  background: var(--error);
  box-shadow: 0 2px 10px rgba(239, 68, 68, 0.35);
  animation: stopPulse 1.5s ease-in-out infinite;
}
.send-btn.stop-mode:hover {
  background: #dc2626;
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4);
}

/* ================================================================
   Profile menu + Settings modal
   ================================================================ */

.profile-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--mayer), var(--mayer-deep));
  color: white;
  border: none;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.profile-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 80;
  overflow: hidden;
  animation: slideDown 0.2s var(--ease-out);
  display: none;
}

.profile-menu.open { display: block; }

.profile-menu-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.profile-menu-name {
  font-size: 14px; font-weight: 600; color: var(--text);
}

.profile-menu-role {
  font-size: 11px; color: var(--text-muted); margin-top: 2px; text-transform: capitalize;
}

.profile-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  border: none; background: none; width: 100%; text-align: left;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
}

.profile-menu-item:hover { background: var(--surface-hover); color: var(--text); }
.profile-menu-item svg { flex-shrink: 0; opacity: 0.6; }

.theme-toggle-track {
  width: 36px; height: 20px;
  border-radius: 10px;
  background: var(--border);
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.theme-toggle-track.active { background: var(--mayer); }

.theme-toggle-thumb {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: white;
  position: absolute;
  top: 2px; left: 2px;
  transition: left 0.2s var(--ease-out);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.theme-toggle-track.active .theme-toggle-thumb { left: 18px; }

/* Settings modal */
.settings-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 90;
  display: none;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s;
}

.settings-overlay.open { display: flex; }

.settings-modal {
  width: 90%; max-width: 480px;
  max-height: 85vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-y: auto;
  animation: scaleIn 0.25s var(--ease-out);
  -webkit-overflow-scrolling: touch;
}

.settings-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: var(--surface);
  z-index: 1;
}

.settings-header h2 { font-size: 17px; font-weight: 600; }

/* Bigger close button for settings */
/* Avatar upload */
.avatar-upload {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--mayer), var(--mayer-deep));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(37,99,235,0.3);
  transition: transform 0.15s;
}
.avatar-upload:hover { transform: scale(1.05); }
.avatar-upload img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.avatar-upload-initials {
  font-size: 28px;
  font-weight: 800;
  color: white;
}
.avatar-upload-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.15s;
}
.avatar-upload:hover .avatar-upload-overlay { opacity: 1; }

.settings-close-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.settings-close-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.settings-body { padding: 20px; }

.settings-section {
  margin-bottom: 24px;
}

.settings-section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* Job title dropdown */
.settings-select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%236b6b69' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.settings-select:focus {
  border-color: var(--mayer);
  box-shadow: 0 0 0 3px var(--mayer-glow);
}
.settings-select option {
  background: var(--surface);
  color: var(--text);
}

.settings-role-hint {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 8px;
  line-height: 1.5;
  min-height: 18px;
}

/* Personality slider */
.slider-row {
  margin-bottom: 16px;
}

.slider-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.slider-name { font-size: 13px; font-weight: 500; color: var(--text); }
.slider-value { font-size: 12px; color: var(--text-dim); min-width: 60px; text-align: right; }

.slider-track {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}

.slider-track::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--mayer);
  box-shadow: 0 2px 6px rgba(37,99,235,0.3);
  cursor: pointer;
  transition: transform 0.15s;
}

.slider-track::-webkit-slider-thumb:hover { transform: scale(1.15); }

.slider-track::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--mayer);
  box-shadow: 0 2px 6px rgba(37,99,235,0.3);
  border: none;
  cursor: pointer;
}

.slider-endpoints {
  display: flex; justify-content: space-between;
  font-size: 10px; color: var(--text-muted);
  margin-top: 2px;
}

/* Custom prompt textarea */
.settings-textarea {
  width: 100%;
  min-height: 80px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  line-height: 1.5;
  resize: vertical;
  outline: none;
}

.settings-textarea:focus {
  border-color: var(--mayer);
  box-shadow: 0 0 0 2px var(--mayer-glow);
}

.settings-textarea-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.settings-save-btn {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--mayer);
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  margin-top: 8px;
}

.settings-save-btn:hover { background: var(--mayer-dark); }
.settings-save-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.settings-status {
  font-size: 12px;
  text-align: center;
  margin-top: 8px;
  min-height: 18px;
}

.settings-status.success { color: var(--haiku); }
.settings-status.error { color: var(--error); }

/* Settings tabs */
.settings-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.settings-tabs::-webkit-scrollbar { display: none; }

.settings-tab {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  font-family: inherit;
}
.settings-tab:hover { color: var(--text-dim); }
.settings-tab.active {
  color: var(--mayer-light);
  border-bottom-color: var(--mayer);
}

.settings-panel { min-height: 200px; }

/* Profile inputs */
.settings-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.settings-input:focus {
  border-color: var(--mayer);
  box-shadow: 0 0 0 3px var(--mayer-glow);
}
.settings-input::placeholder { color: var(--text-muted); }

.settings-hint {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.5;
  margin-bottom: 12px;
}

/* Action buttons */
.settings-action-btn {
  padding: 9px 18px;
  border: 1.5px solid var(--mayer);
  border-radius: 10px;
  background: none;
  color: var(--mayer-light);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.settings-action-btn:hover {
  background: var(--mayer);
  color: white;
}
.settings-action-btn.secondary {
  border-color: var(--border);
  color: var(--text-dim);
}
.settings-action-btn.secondary:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.settings-action-btn.danger {
  border-color: var(--error);
  color: var(--error);
}
.settings-action-btn.danger:hover {
  background: var(--error);
  color: white;
}

.usage-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Usage plan card */
.usage-plan-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 12px;
}
.usage-plan-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}
.usage-plan-price {
  font-size: 14px;
  color: var(--text-dim);
}

/* Usage bar */
.usage-bar-wrap { margin-top: 4px; }
.usage-bar-track {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.usage-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--mayer), var(--mayer-light));
  border-radius: 4px;
  transition: width 0.5s var(--ease-out);
}
.usage-bar-fill.high { background: linear-gradient(90deg, #f59e0b, #ef4444); }
.usage-bar-label {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 6px;
}

/* Features list */
.usage-features {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.usage-feature-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dim);
}
.usage-feature-check {
  color: var(--haiku);
  font-weight: 700;
}
.usage-feature-lock {
  color: var(--text-muted);
}

/* Memory list in settings */
.settings-memory-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 300px;
  overflow-y: auto;
}

.settings-memory-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.settings-memory-item-body {
  flex: 1;
  min-width: 0;
}
.settings-memory-key {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.settings-memory-value {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.4;
  word-break: break-word;
}
.settings-memory-cat {
  font-size: 10px;
  color: var(--text-muted);
  background: var(--surface);
  padding: 2px 6px;
  border-radius: 4px;
  margin-top: 4px;
  display: inline-block;
}
.settings-memory-del {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
  border-radius: 4px;
  transition: all 0.15s;
}
.settings-memory-del:hover {
  color: var(--error);
  background: rgba(239,68,68,0.1);
}
.settings-memory-empty {
  font-size: 13px;
  color: var(--text-muted);
  padding: 20px;
  text-align: center;
}

/* About page */
.settings-about-logo {
  text-align: center;
  padding: 20px 0 16px;
}
.settings-about-name {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
}
.settings-about-tagline {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 4px;
}
.settings-about-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.settings-about-row span:first-child { color: var(--text-dim); }
.settings-about-row span:last-child { color: var(--text); font-weight: 500; }

.settings-caps {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.settings-cap-badge {
  font-size: 11px;
  padding: 4px 10px;
  background: var(--mayer-glow);
  color: var(--mayer-light);
  border-radius: 8px;
  font-weight: 500;
}

@media (max-width: 480px) {
  .settings-modal {
    width: 100%;
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    max-height: 92vh;
    margin-top: auto;
  }
  .settings-overlay { align-items: flex-end; }
  .settings-tabs { overflow-x: auto; flex-wrap: nowrap; }
  .settings-tab { padding: 10px 12px; font-size: 13px; flex-shrink: 0; }
  .settings-body { padding: 16px; }
  .settings-section { margin-bottom: 18px; }
  .settings-input { font-size: 16px; padding: 12px 14px; }
  .settings-select { font-size: 16px; padding: 12px 14px; }
  .settings-save-btn { font-size: 16px; padding: 14px; }
  .settings-action-btn { font-size: 14px; padding: 10px 16px; }
  .settings-header { padding: 14px 16px; }
  .settings-close-btn { font-size: 32px; padding: 6px 10px; }
  .avatar-upload { width: 72px; height: 72px; }
  .avatar-upload-initials { font-size: 24px; }
}

/* ================================================================
   Contacts sidebar tab
   ================================================================ */

.contacts-search-wrap {
  padding: 8px 12px;
}

.contacts-search {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
.contacts-search:focus { border-color: var(--mayer); }
.contacts-search::placeholder { color: var(--text-muted); }

.contacts-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 8px;
}

.contact-group-header {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 10px 8px 4px;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
[data-theme="light"] .contact-group-header { background: #f8f9fb; }

/* Contact card in sidebar */
.contact-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 8px;
  transition: background 0.15s;
  cursor: pointer;
}
.contact-card:hover { background: var(--surface-hover); }

.contact-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--mayer), var(--mayer-deep));
  color: white;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

.contact-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contact-card-title {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contact-card-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
.contact-card:hover .contact-card-actions { opacity: 1; }

.contact-action-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}
.contact-action-btn:hover {
  background: var(--mayer-glow);
  border-color: var(--mayer);
  color: var(--mayer-light);
}

.verified-badge {
  color: var(--haiku);
  font-size: 10px;
  font-weight: 700;
  margin-left: 3px;
}

.contact-source-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  margin-left: 4px;
  vertical-align: middle;
}
.contact-source-badge.hunter {
  background: rgba(245,158,11,0.15);
  color: #f59e0b;
}
.contact-source-badge.bcard {
  background: rgba(34,197,94,0.15);
  color: #22c55e;
}

/* ── Contact detail modal ── */
.contact-detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.2s;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.contact-detail-modal {
  width: 90%;
  max-width: 400px;
  max-height: 85vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow-y: auto;
  animation: scaleIn 0.25s var(--ease-out);
}

.cd-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.cd-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--mayer), var(--mayer-deep));
  color: white;
  font-size: 18px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 12px rgba(37,99,235,0.3);
}

.cd-header-info { flex: 1; min-width: 0; }

.cd-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.cd-title {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 2px;
}

.cd-company {
  font-size: 12px;
  color: var(--mayer-light);
  margin-top: 2px;
  font-weight: 500;
}

.cd-body {
  padding: 16px 20px;
}

.cd-field {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.cd-field:last-child { border-bottom: none; }

.cd-field-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.cd-field-value {
  font-size: 14px;
  color: var(--text);
  word-break: break-word;
}

.cd-link {
  color: var(--mayer-light);
  text-decoration: none;
  display: block;
}
.cd-link:hover { text-decoration: underline; }

.cd-verified {
  font-size: 10px;
  font-weight: 600;
  color: var(--haiku);
  background: rgba(34,197,94,0.1);
  padding: 1px 6px;
  border-radius: 4px;
}

.cd-invalid {
  font-size: 10px;
  font-weight: 600;
  color: var(--error);
  background: rgba(239,68,68,0.1);
  padding: 1px 6px;
  border-radius: 4px;
}

.cd-actions {
  padding: 12px 20px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cd-action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: none;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  font-family: inherit;
}
.cd-action-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--text-muted);
}
.cd-action-btn.primary {
  background: var(--mayer);
  border-color: var(--mayer);
  color: white;
  flex: 1 1 100%;
  justify-content: center;
}
.cd-action-btn.primary:hover {
  background: var(--mayer-dark);
}
.cd-action-btn.danger {
  border-color: transparent;
  color: var(--text-muted);
}
.cd-action-btn.danger:hover {
  color: var(--error);
  border-color: var(--error);
  background: rgba(239,68,68,0.05);
}

@media (max-width: 480px) {
  .contact-detail-modal { width: 100%; max-width: 100%; border-radius: 16px 16px 0 0; margin-top: auto; }
  .contact-card-actions { opacity: 1; } /* always show on mobile — no hover */
}

.contacts-empty {
  font-size: 13px;
  color: var(--text-muted);
  padding: 24px 16px;
  text-align: center;
  line-height: 1.5;
}

/* Notification badge */
.notif-badge {
  position: relative;
  top: -1px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  margin-left: 4px;
  background: var(--error);
  color: white;
  font-size: 9px;
  font-weight: 700;
  border-radius: 8px;
  line-height: 1;
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 250;
  opacity: 0;
  transition: all 0.3s var(--ease-out);
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Quote card */
.quote-card {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  animation: slideUp 0.3s var(--ease-out);
}
.quote-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.quote-card table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.quote-card th {
  background: var(--surface);
  padding: 6px 10px;
  text-align: left;
  font-weight: 600;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}
.quote-card td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.quote-card-total {
  display: flex;
  justify-content: space-between;
  padding: 10px 14px;
  font-weight: 700;
  font-size: 14px;
  background: var(--surface);
}
.quote-card-warnings {
  padding: 8px 14px;
  font-size: 12px;
  color: #f59e0b;
  background: rgba(245,158,11,0.06);
  border-top: 1px solid var(--border);
}
.quote-card-actions {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
}
.quote-action-btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: none;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.quote-action-btn:hover { background: var(--surface-hover); color: var(--text); }
.quote-action-btn.primary { background: var(--mayer); color: white; border-color: var(--mayer); }
.quote-action-btn.primary:hover { background: var(--mayer-dark); }

/* Email card */
.email-card {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  animation: slideUp 0.3s var(--ease-out);
}
.email-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.email-card-subject {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.email-card-to {
  font-size: 12px;
  color: var(--text-dim);
}
.email-card-body {
  padding: 14px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  max-height: 300px;
  overflow-y: auto;
}
.email-card-actions {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
}

.contacts-credit-badge {
  padding: 8px 12px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  border-top: 1px solid var(--border);
}

/* ================================================================
   Document viewer panel (right side)
   ================================================================ */

.doc-panel {
  position: fixed;
  top: 0;
  right: -100%;
  bottom: 0;
  width: 50%;
  min-width: 360px;
  max-width: 700px;
  background: var(--bg);
  border-left: 1px solid var(--border);
  z-index: 60;
  display: flex;
  flex-direction: column;
  transition: right 0.35s var(--ease-out);
  box-shadow: -6px 0 30px rgba(0,0,0,0.4);
}

.doc-panel.open {
  right: 0;
}

.doc-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  gap: 8px;
}

.doc-back-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}
.doc-back-btn:hover { background: var(--surface-hover); color: var(--text); }

@media (max-width: 767px) {
  .doc-back-btn { padding: 8px; }
  .doc-back-btn svg { width: 24px; height: 24px; }
}

.doc-panel-title {
  font-size: 14px;
  font-weight: 600;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doc-panel-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.doc-action-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.doc-action-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--mayer);
}

.doc-panel-body {
  flex: 1;
  overflow: hidden;
  background: #1a1a2e;
}

.doc-panel-body iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* Rendered markdown viewer (GitHub-like dark) */
.doc-rendered {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.doc-export-bar {
  display: flex;
  gap: 8px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.doc-export-btn {
  font-size: 12px;
  font-weight: 500;
  padding: 5px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.doc-export-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--mayer);
}

.doc-markdown {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px 60px;
  font-size: 14px;
  line-height: 1.75;
  color: var(--text);
  -webkit-overflow-scrolling: touch;
}

/* GitHub-like markdown styling in dark theme */
.doc-markdown h1 {
  font-size: 1.7em;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
  margin: 1.6em 0 0.6em;
}

.doc-markdown h2 {
  font-size: 1.35em;
  font-weight: 600;
  color: #fff;
  border-bottom: 1px solid rgba(35, 42, 80, 0.5);
  padding-bottom: 8px;
  margin: 1.3em 0 0.5em;
}

.doc-markdown h3 {
  font-size: 1.1em;
  font-weight: 600;
  color: var(--mayer-light);
  margin: 1.1em 0 0.4em;
}

.doc-markdown strong { color: #fff; }
.doc-markdown em { color: var(--text-dim); }

.doc-markdown code {
  background: rgba(37, 99, 235, 0.1);
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 0.88em;
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  border: 1px solid rgba(37, 99, 235, 0.15);
  color: var(--mayer-light);
}

.doc-markdown pre {
  background: var(--pre-bg, #181817);
  color: #e2e8f0;
  padding: 16px 18px;
  border-radius: 10px;
  overflow-x: auto;
  margin: 14px 0;
  font-size: 13px;
  line-height: 1.5;
  border: 1px solid var(--border);
}

.doc-markdown pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

.doc-markdown a {
  color: var(--mayer-light);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.doc-markdown ul, .doc-markdown ol {
  padding-left: 1.5em;
  margin: 10px 0;
}

.doc-markdown li {
  margin-bottom: 5px;
  line-height: 1.6;
}

.doc-markdown li::marker { color: var(--mayer); }

.doc-markdown table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  margin: 14px 0;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.doc-markdown thead th {
  background: var(--mayer-deep);
  color: white;
  font-weight: 600;
  padding: 9px 12px;
  text-align: left;
}

.doc-markdown tbody td {
  padding: 8px 12px;
  border-top: 1px solid var(--border);
}

.doc-markdown tbody tr:hover td { background: var(--surface-hover); }

.doc-markdown blockquote {
  border-left: 3px solid var(--mayer);
  padding: 6px 14px;
  margin: 12px 0;
  color: var(--text-dim);
  background: rgba(37, 99, 235, 0.04);
  border-radius: 0 6px 6px 0;
}

.doc-markdown hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 18px 0;
}

@media (max-width: 480px) {
  .doc-markdown { padding: 16px 14px 40px; font-size: 14px; }
  .doc-export-bar { padding: 8px 14px; }
}

/* When doc panel is open, shift the chat area on desktop */
body.doc-open main#chatArea {
  margin-right: 50%;
  transition: margin-right 0.35s var(--ease-out);
}

body.doc-open footer#inputArea {
  right: 50%;
  transition: right 0.35s var(--ease-out);
}

body.doc-open .quick-actions {
  right: 50%;
  transition: right 0.35s var(--ease-out);
}

/* ================================================================
   Desktop layout (sidebar always visible)
   ================================================================ */

@media (min-width: 768px) {
  header#topBar { display: none; }

  aside#sidebar {
    position: relative;
    left: 0;
    width: 280px;
    min-width: 280px;
    box-shadow: none;
    border-right: 1px solid var(--border);
  }

  .overlay { display: none !important; }

  main#chatArea {
    padding-top: 0;
    transition: margin-right 0.35s var(--ease-out);
  }

  .messages { padding: 24px 20px; }
  .msg { max-width: 75%; }
  .quick-actions { padding: 8px 0; left: 280px; transition: right 0.35s var(--ease-out); }
  footer#inputArea {
    padding: 12px 16px;
    padding-bottom: calc(12px + var(--safe-bottom));
    left: 280px;
    transition: right 0.35s var(--ease-out);
  }

  /* Collapsed sidebar — thin icon strip */
  body.sidebar-collapsed aside#sidebar {
    width: 52px;
    min-width: 52px;
  }
  body.sidebar-collapsed .sidebar-logo .logo-text,
  body.sidebar-collapsed .sidebar-tabs,
  body.sidebar-collapsed .sidebar-panel,
  body.sidebar-collapsed .sidebar-footer { display: none; }
  body.sidebar-collapsed .sidebar-header { justify-content: center; padding: 14px 8px; }
  body.sidebar-collapsed .sidebar-header .collapse-btn svg {
    transform: rotate(180deg);
  }
  body.sidebar-collapsed .quick-actions { left: 52px; }
  body.sidebar-collapsed footer#inputArea { left: 52px; }

  /* Doc panel on desktop: 50% width, chat shifts */
  .doc-panel { width: 50%; max-width: 700px; min-width: 400px; }
  body.doc-open main#chatArea { margin-right: 50%; }
  body.doc-open footer#inputArea { right: 50%; }
  body.doc-open .quick-actions { right: 50%; }
}

@media (min-width: 1400px) {
  .messages { max-width: 1000px; }
  .input-row { max-width: 1000px; }
}

/* ================================================================
   Mobile layout — flex column (no position:fixed footer/header)
   This is how ChatGPT / Claude apps handle the keyboard:
   the header, chat, and input are flex children. Only the
   chat area scrolls. When the keyboard opens, the flex
   container shrinks and the chat squishes naturally.
   ================================================================ */

@media (max-width: 767px) {
  body {
    flex-direction: column;
    overflow: hidden;
  }

  /* Header: flex child pinned to top, NOT position:fixed */
  header#topBar {
    position: relative;
    display: flex;
    flex-shrink: 0;
    width: 100%;
  }

  /* Chat: fills remaining space, scrolls internally */
  main#chatArea {
    flex: 1 1 0;
    min-height: 0;  /* critical — lets flex child shrink below content height */
    padding-top: 0;
    padding-bottom: 8px;
    overflow-y: auto;
    overflow-x: hidden;
  }

  /* Footer/input: flex child at bottom, NOT position:fixed */
  footer#inputArea {
    position: relative;
    flex-shrink: 0;
    left: auto;
    right: auto;
    bottom: auto;
  }

  .quick-actions {
    position: relative;
    bottom: auto;
    left: auto;
    right: auto;
    flex-shrink: 0;
  }

  .messages { padding: 12px 10px; }

  /* Doc panel fullscreen on mobile */
  .doc-panel {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  body.doc-open main#chatArea { margin-right: 0; }
  body.doc-open footer#inputArea { right: auto; }
}

/* When keyboard is open (detected by JS), force body height to visible viewport */
body.keyboard-open {
  height: var(--vv-height, 100dvh) !important;
}

body.keyboard-open .quick-actions,
body.keyboard-open .guest-counter,
body.keyboard-open .install-banner,
body.keyboard-open .welcome-screen {
  display: none !important;
}

@media (max-width: 480px) {
  .msg {
    max-width: 92%;
    padding: 10px 14px;
    font-size: 15px;
  }

  .messages { padding: 10px 8px; }

  .quick-actions {
    padding: 6px 8px;
  }

  .chip {
    padding: 7px 14px;
    font-size: 12px;
  }

  footer#inputArea {
    padding: 8px 10px;
    padding-bottom: calc(8px + var(--safe-bottom));
  }

  #msgInput {
    padding: 9px 14px;
  }

  .send-btn {
    width: 38px;
    height: 38px;
  }

  .attach-btn {
    width: 34px;
    height: 34px;
  }
  .attach-btn svg { width: 16px; height: 16px; }

  .mic-btn {
    width: 34px;
    height: 34px;
  }

  .attach-preview { margin-bottom: 4px; }
  .attach-thumb { width: 56px; height: 56px; }

  .welcome-screen {
    padding: 40px 16px 16px;
  }

  .welcome-logo-icon {
    width: 52px;
    height: 52px;
    font-size: 24px;
    border-radius: 14px;
  }

  .welcome-title { font-size: 22px; }
  .welcome-subtitle { font-size: 13px; margin-bottom: 20px; }
  .example-btn { padding: 10px 12px; font-size: 13px; }

  .msg.assistant .msg-content pre {
    font-size: 11px;
    padding: 10px 12px;
  }

  .msg.assistant .msg-content table {
    font-size: 11px;
  }
}

/* ================================================================
   PWA Install Banner
   ================================================================ */

.install-banner {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 420px;
  width: calc(100% - 24px);
  z-index: 180;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.35s var(--ease-out);
}

.install-banner.closing {
  opacity: 0;
  transform: translateX(-50%) translateY(10px);
  transition: all 0.3s;
}

.install-banner-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--mayer), var(--mayer-deep));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  color: white;
  flex-shrink: 0;
}

.install-banner-text {
  flex: 1;
  min-width: 0;
}

.install-banner-text strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.install-banner-text span {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.3;
}

.install-banner-btn {
  background: var(--mayer);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}

.install-banner-btn:hover { background: var(--mayer-dark); }

.install-banner-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  flex-shrink: 0;
}

.install-banner-close:hover { color: var(--text); }

/* In standalone PWA mode — hide browser-related UI, extra safe-area padding */
body.pwa-standalone header#topBar {
  padding-top: calc(var(--safe-top) + 8px);
}

body.pwa-standalone footer#inputArea {
  padding-bottom: calc(12px + var(--safe-bottom) + 4px);
}

/* iOS install guide (expanded) */
.install-banner.install-guide {
  flex-direction: column;
  align-items: stretch;
  max-width: 340px;
  padding: 20px;
  bottom: auto;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.install-guide-content {
  width: 100%;
}

.install-guide-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
  text-align: center;
}

.install-guide-steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.install-guide-step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.4;
}

.install-guide-step strong { color: var(--text); }

.install-step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--mayer);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.install-banner.install-guide.closing {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.95);
  transition: all 0.3s;
}

@media (max-width: 480px) {
  .install-banner { bottom: 72px; padding: 10px 12px; gap: 10px; }
  .install-banner-icon { width: 36px; height: 36px; font-size: 16px; }
  .install-banner-text strong { font-size: 13px; }
  .install-banner-text span { font-size: 11px; }
  .install-banner-btn { padding: 7px 12px; font-size: 12px; }
  .install-banner.install-guide { bottom: auto; padding: 18px; }
}

/* ================================================================
   Accessibility: Scale up for mobile (older eyes, 55-65 age range)
   Uses the phone's DPI to scale proportionally — high-DPI phones
   get bigger text and touch targets automatically.
   ================================================================ */

@media (max-width: 767px) {
  /* Base font bump: 16px → 17px on mobile */
  html { font-size: 17px; }

  /* Chat messages — main reading area, needs to be comfortable */
  .msg { font-size: 16px; line-height: 1.65; padding: 12px 16px; }
  .msg.assistant .msg-content { font-size: 16px; line-height: 1.65; }
  .msg.assistant .msg-content li { margin: 4px 0; }
  .msg.assistant .msg-content h2 { font-size: 19px; }
  .msg.assistant .msg-content h3 { font-size: 17px; }
  .msg.assistant .msg-content strong { font-size: inherit; }
  .msg.assistant .msg-content code { font-size: 14px; padding: 3px 7px; }
  .msg.assistant .msg-content pre { font-size: 13px; }
  .msg.assistant .msg-content table { font-size: 14px; }
  .msg.assistant .msg-content th,
  .msg.assistant .msg-content td { padding: 8px 10px; }

  /* Input area — bigger text field and buttons */
  #msgInput { font-size: 17px; padding: 12px 16px; min-height: 48px; }
  .send-btn { width: 46px; height: 46px; }
  .mic-btn { width: 42px; height: 42px; }
  .attach-btn { width: 40px; height: 40px; }
  .attach-btn svg { width: 20px; height: 20px; }

  /* Top bar */
  header#topBar { height: 60px; }
  .topbar-title { font-size: 19px; }

  /* Sidebar text */
  .sidebar-tab { font-size: 14px; padding: 10px 14px; }
  .conv-item { font-size: 14px; padding: 12px; }
  .conv-item-title { font-size: 14px; }
  .conv-item-date { font-size: 12px; }

  /* Contact cards */
  .contact-card { padding: 10px 12px; }
  .contact-card-name { font-size: 15px; }
  .contact-card-title { font-size: 13px; }
  .contact-avatar { width: 38px; height: 38px; font-size: 13px; }
  .contact-action-btn { width: 34px; height: 34px; }
  .contact-group-header { font-size: 12px; padding: 12px 8px 6px; }

  /* Welcome screen */
  .welcome-title { font-size: 26px; }
  .welcome-subtitle { font-size: 15px; line-height: 1.6; }
  .example-btn { font-size: 15px; padding: 12px 14px; }

  /* Profile & settings */
  .profile-btn { width: 36px; height: 36px; font-size: 14px; }
  .settings-tab { font-size: 14px; }
  .settings-input { font-size: 16px; padding: 12px 16px; }
  .settings-select { font-size: 16px; padding: 12px 16px; }
  .settings-textarea { font-size: 15px; }
  .settings-section-title { font-size: 13px; }

  /* Tool status blocks */
  .tool-block { font-size: 14px; }

  /* Tier badge */
  .tier-badge { font-size: 11px; padding: 3px 8px; }
  .msg-meta { font-size: 12px; }

  /* Guest popup */
  .guest-popup-card h2 { font-size: 22px; }
  .guest-popup-card p { font-size: 15px; }
  .guest-popup-btn { font-size: 16px; padding: 14px; }

  /* Routing indicator */
  .routing-indicator { font-size: 13px; }

  /* Input disclaimer */
  .input-disclaimer { font-size: 11px; }
}

/* Extra bump on small high-DPI phones (iPhone Pro, Samsung Galaxy, etc.) */
@media (max-width: 480px) and (min-resolution: 2dppx) {
  .msg { font-size: 17px; }
  .msg.assistant .msg-content { font-size: 17px; }
  #msgInput { font-size: 18px; }
  .example-btn { font-size: 16px; }
}

/* Large phones / phablets (iPhone Plus/Max, Galaxy Ultra) — even roomier */
@media (min-width: 390px) and (max-width: 767px) and (min-resolution: 3dppx) {
  .msg { padding: 14px 18px; }
  .send-btn { width: 48px; height: 48px; }
  .mic-btn { width: 44px; height: 44px; }
}
