/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:       #4A90D9;
  --primary-light: #EBF5FB;
  --accent:        #E67E22;
  --success:       #27AE60;
  --danger:        #E74C3C;
  --purple:        #9B59B6;
  --text:          #2C3E50;
  --text-muted:    #7F8C8D;
  --border:        #E8ECEF;
  --bg:            #F5F7FA;
  --white:         #FFFFFF;
  --shadow:        0 2px 12px rgba(0,0,0,0.08);
  --shadow-hover:  0 6px 24px rgba(0,0,0,0.14);
  --radius:        14px;
  --radius-sm:     8px;
  --nav-h:         64px;
  --header-h:      56px;
  --transition:    0.2s ease;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
}

/* ============================================================
   LAYOUT SHELL
   ============================================================ */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 1024px;
  margin: 0 auto;
  background: var(--white);
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(0,0,0,0.08);
}

/* Header */
.app-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: relative;
  flex-shrink: 0;
  z-index: 10;
}
.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-logo-img {
  height: 44px;
  width: auto;
  object-fit: contain;
}
#header-title { display: none; }
.header-logo1 {
  position: absolute;
  left: 16px;
  height: 40px;
  width: auto;
  object-fit: contain;
}
.app-header h1 {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.3px;
}
.auth-logo-img {
  height: 48px;
  width: auto;
  object-fit: contain;
  margin-bottom: 4px;
}
.header-back-btn {
  position: absolute;
  left: 16px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 22px;
  color: var(--primary);
  padding: 4px 8px;
  border-radius: 6px;
  transition: background var(--transition);
  display: none;
}
.header-back-btn:hover { background: var(--primary-light); }
.header-back-btn.visible { display: flex; align-items: center; }

.header-action-btn {
  position: absolute;
  right: 16px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 20px;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 6px;
  transition: background var(--transition);
}
.header-action-btn:hover { background: var(--bg); color: var(--text); }

/* Main content area */
.tab-content-area {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.tab-panel {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  display: none;
  padding-bottom: var(--nav-h);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.tab-panel::-webkit-scrollbar { width: 4px; }
.tab-panel::-webkit-scrollbar-track { background: transparent; }
.tab-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.tab-panel.active { display: block; }

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 1024px;
  height: var(--nav-h);
  background: var(--white);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
}
.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  transition: color var(--transition);
  padding: 8px 4px;
}
.nav-btn .nav-icon { font-size: 22px; line-height: 1; }
.nav-btn.active { color: var(--primary); }
.nav-btn.active .nav-icon { transform: scale(1.05); }

/* ============================================================
   TAB 1 – AI CREATION
   ============================================================ */
.creation-header {
  padding: 20px 20px 8px;
  text-align: center;
}
.creation-header .tagline {
  font-size: 13px;
  color: var(--text-muted);
}

.category-section { padding: 0 16px 8px; }
.category-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 16px 4px 10px;
  display: block;
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.tool-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 12px;
  cursor: pointer;
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  overflow: hidden;
}
.tool-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-1px);
  border-color: var(--primary);
}
.tool-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.tool-card-body { min-width: 0; }
.tool-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tool-card-desc {
  font-size: 11.5px;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
  margin-top: 2px;
}

/* ============================================================
   OVERLAY PANELS  — all slide-in panels share this base.
   position:absolute keeps them inside #app (max-width:1024px)
   rather than bleeding to the full viewport on desktop.
   ============================================================ */
.overlay-panel {
  position: absolute;
  top: var(--header-h);
  left: 0;
  right: 0;
  bottom: var(--nav-h);
  width: 100%;
  background: #fff;
  z-index: 200;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}
.overlay-panel.open { transform: translateX(0); }

/* ============================================================
   TOOL DETAIL VIEW (after clicking a tool card)
   ============================================================ */
#tool-detail-panel {
  /* layout handled by .overlay-panel */
}

.tool-detail-info {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}
.tool-detail-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}
.tool-detail-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  flex-shrink: 0;
}
.tool-detail-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}
.tool-detail-desc {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
}

.examples-section { padding: 16px 20px; overflow-y: auto; max-height: 220px; flex-shrink: 0; }
.examples-section.hidden { display: none; }
.examples-title {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 10px;
  font-weight: 600;
}
.example-prompt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  margin-bottom: 8px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  font-size: 14px;
  color: var(--text);
  gap: 8px;
}
.example-prompt:hover { background: var(--primary-light); color: var(--primary); }
.example-prompt .arrow { color: var(--text-muted); font-size: 16px; flex-shrink: 0; }

.tool-chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ============================================================
   CHAT INTERFACE  (shared by tool-detail & Tab 3)
   ============================================================ */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.chat-bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
}
.chat-bubble.user {
  align-self: flex-end;
  background: var(--primary);
  color: var(--white);
  border-bottom-right-radius: 4px;
}
.chat-bubble.assistant {
  align-self: flex-start;
  background: var(--bg);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.chat-bubble.assistant strong { color: var(--text); }
.chat-bubble.error {
  align-self: flex-start;
  background: #FDEDEC;
  color: var(--danger);
  border-bottom-left-radius: 4px;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  max-width: 80px;
}
.typing-dot {
  width: 7px; height: 7px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typingPulse 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingPulse {
  0%, 60%, 100% { transform: scale(1); opacity: 0.5; }
  30% { transform: scale(1.3); opacity: 1; }
}

/* Chat input bar */
.chat-input-bar {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--white);
  display: flex;
  align-items: flex-end;
  gap: 10px;
}
.chat-input-wrap {
  flex: 1;
  position: relative;
}
.chat-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 22px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  line-height: 1.5;
  max-height: 120px;
  transition: border-color var(--transition);
  background: var(--bg);
  color: var(--text);
}
.chat-input:focus { border-color: var(--primary); background: var(--white); }
.chat-input::placeholder { color: var(--text-muted); }

.send-btn {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--white);
  flex-shrink: 0;
  transition: background var(--transition), transform var(--transition);
  align-self: flex-end;
}
.send-btn:hover { background: #3a7cc7; transform: scale(1.05); }
.send-btn:disabled { background: var(--border); cursor: not-allowed; transform: none; }

/* Clear chat button */
.clear-chat-btn {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 4px;
  display: none;
}
.clear-chat-btn:hover { color: var(--danger); }
.clear-chat-btn.visible { display: flex; }

/* ============================================================
   TAB 2 – AI ASSISTANT
   ============================================================ */
.assistant-filter-bar {
  padding: 12px 16px 4px;
  overflow-x: auto;
  display: flex;
  gap: 8px;
  scrollbar-width: none;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}
.assistant-filter-bar::-webkit-scrollbar { display: none; }

.filter-chip {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--white);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
  flex-shrink: 0;
}
.filter-chip:hover { border-color: var(--primary); color: var(--primary); }
.filter-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--white);
}

.assistants-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 16px;
}

.assistant-card {
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow var(--transition), transform var(--transition);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.assistant-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}
.assistant-card-header {
  padding: 12px 14px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.assistant-card-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--white);
  flex: 1;
  min-width: 0;
}
.card-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.assistant-fav-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 22px;
  color: rgba(255,255,255,0.7);
  padding: 0 2px;
  line-height: 1;
  transition: color 0.15s, transform 0.15s;
  display: flex;
  align-items: center;
}
.assistant-fav-btn:hover { color: #fff; transform: scale(1.2); }
.assistant-fav-btn.active { color: #FFD700; }
.assistant-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 12px;
  background: rgba(0,0,0,0.25);
  color: var(--white);
  white-space: nowrap;
}
.assistant-card-body {
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  flex: 1;
}

/* Favorites panel items */
.fav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: opacity var(--transition);
}
.fav-item:last-child { border-bottom: none; }
.fav-item:hover { opacity: 0.7; }
.fav-item-dot {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  flex-shrink: 0;
}
.fav-item-info { flex: 1; min-width: 0; }
.fav-item-name { font-size: 15px; font-weight: 600; color: var(--text); }
.fav-item-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Assistant chat view — layout handled by .overlay-panel */

.assistant-chat-info {
  padding: 14px 20px;
  background: var(--primary-light);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.assistant-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--white);
  font-weight: 700;
  flex-shrink: 0;
}
.assistant-chat-name { font-size: 16px; font-weight: 700; color: var(--text); }
.assistant-chat-desc { font-size: 12px; color: var(--text-muted); }

/* ============================================================
   TAB 3 – DIRECT CHAT
   ============================================================ */
.chat-tab-wrap {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.chat-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  gap: 12px;
  color: var(--text-muted);
}
.chat-empty-icon { font-size: 52px; }
.chat-empty-title { font-size: 18px; font-weight: 700; color: var(--text); }
.chat-empty-sub { font-size: 14px; text-align: center; max-width: 280px; }

.chat-starters {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 8px;
  width: 100%;
  max-width: 480px;
}
.chat-starter-btn {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: all var(--transition);
  line-height: 1.4;
}
.chat-starter-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

/* ============================================================
   TAB 4 – PROFILE
   ============================================================ */
.profile-wrap { padding: 0 0 20px; }

.profile-hero {
  background: linear-gradient(135deg, var(--primary) 0%, #5B6EF7 100%);
  padding: 32px 24px 28px;
  text-align: center;
  color: var(--white);
}
.profile-avatar-wrap {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  color: var(--white);
  margin: 0 auto 14px;
  border: 3px solid rgba(255,255,255,0.4);
}
.profile-name { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.profile-tagline { font-size: 14px; opacity: 0.85; margin-bottom: 4px; }
.profile-member-since { font-size: 12px; opacity: 0.7; }

.edit-profile-btn {
  margin-top: 14px;
  padding: 8px 20px;
  background: rgba(255,255,255,0.2);
  border: 1.5px solid rgba(255,255,255,0.4);
  border-radius: 20px;
  color: var(--white);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}
.edit-profile-btn:hover { background: rgba(255,255,255,0.3); }

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin: 16px 0 0;
}
.stat-item {
  background: var(--white);
  padding: 14px 8px;
  text-align: center;
}
.stat-number { font-size: 22px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.profile-section { padding: 16px 20px 0; }
.profile-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
}

.profile-menu-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: color var(--transition);
}
.profile-menu-item:last-child { border-bottom: none; }
.profile-menu-item:hover { color: var(--primary); }
.profile-menu-icon { font-size: 20px; width: 28px; text-align: center; }
.profile-menu-label { flex: 1; font-size: 15px; font-weight: 500; }
.profile-menu-value { font-size: 13px; color: var(--text-muted); }
.profile-menu-arrow { font-size: 16px; color: var(--border); }

/* API Key setup section */
.api-key-section {
  margin: 16px 20px 0;
  background: #FFF8E7;
  border: 1.5px solid #F39C12;
  border-radius: var(--radius);
  padding: 16px;
}
.api-key-title {
  font-size: 14px;
  font-weight: 700;
  color: #E67E22;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.api-key-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.5;
}
.api-key-input-wrap {
  display: flex;
  gap: 8px;
}
.api-key-input {
  flex: 1;
  padding: 9px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: monospace;
  outline: none;
  transition: border-color var(--transition);
  color: var(--text);
}
.api-key-input:focus { border-color: var(--primary); }
.api-key-save-btn {
  padding: 9px 16px;
  background: var(--primary);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition);
}
.api-key-save-btn:hover { background: #3a7cc7; }
.api-key-status {
  margin-top: 8px;
  font-size: 12px;
  display: none;
}
.api-key-status.success { color: var(--success); display: block; }
.api-key-status.error { color: var(--danger); display: block; }

/* ============================================================
   MODAL – EDIT PROFILE
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-sheet {
  background: var(--white);
  width: 100%;
  max-width: 1024px;
  border-radius: 20px 20px 0 0;
  padding: 24px 20px 32px;
  animation: slideUp 0.25s ease;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.modal-handle {
  width: 40px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 20px;
}
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 20px; }
.modal-field { margin-bottom: 16px; }
.modal-label { font-size: 13px; color: var(--text-muted); margin-bottom: 6px; display: block; }
.modal-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition);
  color: var(--text);
}
.modal-input:focus { border-color: var(--primary); }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-btn {
  flex: 1;
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
}
.modal-btn.secondary { background: var(--bg); color: var(--text); }
.modal-btn.secondary:hover { background: var(--border); }
.modal-btn.primary { background: var(--primary); color: var(--white); }
.modal-btn.primary:hover { background: #3a7cc7; }

/* ============================================================
   TOAST NOTIFICATION
   ============================================================ */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--white);
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  z-index: 300;
  opacity: 0;
  transition: all 0.3s ease;
  white-space: nowrap;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================================================
   RESPONSIVE – wider screens get 3 or 4 columns
   ============================================================ */
@media (min-width: 600px) {
  .tools-grid { grid-template-columns: repeat(3, 1fr); }
  .assistants-grid { grid-template-columns: repeat(3, 1fr); }
  .chat-starters { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 800px) {
  .tools-grid { grid-template-columns: repeat(4, 1fr); }
  .assistants-grid { grid-template-columns: repeat(4, 1fr); }
}

/* Markdown-ish formatting in chat bubbles */
.chat-bubble.assistant code {
  background: rgba(0,0,0,0.06);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: "Courier New", monospace;
  font-size: 0.9em;
}
.chat-bubble.assistant pre {
  background: #1E2A3A;
  color: #E8EDF2;
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 6px 0;
  font-size: 12.5px;
  line-height: 1.5;
}
.chat-bubble.assistant pre code { background: none; padding: 0; color: inherit; }
.chat-bubble.assistant ul, .chat-bubble.assistant ol { padding-left: 20px; margin: 4px 0; }
.chat-bubble.assistant li { margin: 3px 0; }
.chat-bubble.assistant h1,.chat-bubble.assistant h2,.chat-bubble.assistant h3 {
  font-weight: 700; margin: 8px 0 4px;
}

/* ============================================================
   AUTH – SIGN IN / CREATE ACCOUNT (Profile tab)
   ============================================================ */

.auth-wall {
  padding: 32px 24px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.auth-wall-logo { font-size: 44px; margin-bottom: 12px; }
.auth-wall-title { font-size: 22px; font-weight: 800; color: var(--text); margin-bottom: 6px; }
.auth-wall-sub {
  font-size: 14px; color: var(--text-muted);
  text-align: center; max-width: 280px; line-height: 1.6; margin-bottom: 28px;
}

/* Google button */
.google-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; max-width: 340px;
  padding: 13px 20px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px; font-weight: 600; color: var(--text);
  cursor: pointer; transition: all var(--transition);
  box-shadow: var(--shadow);
}
.google-btn:hover { border-color: #4285F4; box-shadow: 0 4px 16px rgba(66,133,244,0.15); }
.google-btn .google-icon {
  width: 20px; height: 20px; flex-shrink: 0;
}

/* Divider */
.auth-divider {
  display: flex; align-items: center; gap: 12px;
  width: 100%; max-width: 340px; margin: 20px 0;
  color: var(--text-muted); font-size: 13px;
}
.auth-divider::before, .auth-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}

/* Auth form */
.auth-form { width: 100%; max-width: 340px; }
.auth-field { margin-bottom: 12px; }
.auth-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 5px; }
.auth-input {
  width: 100%; padding: 11px 14px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit; outline: none;
  transition: border-color var(--transition); color: var(--text);
  background: var(--white);
}
.auth-input:focus { border-color: var(--primary); }

/* Name field – only shown on sign-up */
#auth-name-field { display: none; }
#auth-name-field.visible { display: block; }

.auth-submit-btn {
  width: 100%; padding: 13px;
  background: var(--primary); color: #fff;
  border: none; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 700; cursor: pointer;
  transition: background var(--transition); margin-top: 4px;
}
.auth-submit-btn:hover { background: #3a7cc7; }
.auth-submit-btn:disabled { background: var(--border); cursor: not-allowed; }

.auth-toggle {
  text-align: center; margin-top: 16px;
  font-size: 13px; color: var(--text-muted);
}
.auth-toggle-link {
  color: var(--primary); font-weight: 600;
  cursor: pointer; text-decoration: underline;
}

.auth-forgot {
  text-align: right; margin-top: -6px; margin-bottom: 10px;
  font-size: 12px;
}
.auth-forgot-link {
  color: var(--text-muted); cursor: pointer;
  text-decoration: underline; font-size: 12px;
}
.auth-forgot-link:hover { color: var(--primary); }

.auth-error {
  background: #FDEDEC; color: var(--danger);
  border-radius: var(--radius-sm); padding: 10px 13px;
  font-size: 13px; margin-bottom: 10px; display: none;
  line-height: 1.4;
}
.auth-error.visible { display: block; }

.auth-terms {
  font-size: 11px; color: var(--text-muted);
  text-align: center; margin-top: 20px; line-height: 1.6;
  max-width: 300px;
}

/* ── Signed-in profile avatar (supports photo URL from Google) */
.profile-avatar-img {
  width: 80px; height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(255,255,255,0.5);
  margin: 0 auto 14px;
  display: block;
}

.sign-out-btn {
  margin-top: 14px;
  padding: 8px 20px;
  background: rgba(255,255,255,0.15);
  border: 1.5px solid rgba(255,255,255,0.35);
  border-radius: 20px;
  color: #fff;
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background var(--transition);
}
.sign-out-btn:hover { background: rgba(255,255,255,0.25); }

.auth-provider-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; opacity: 0.75; margin-top: 3px;
}

/* ============================================================
   FREEMIUM – LOCKED / PRO STYLES
   ============================================================ */

/* Pro badge shown on locked tool cards */
.pro-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: linear-gradient(135deg, #F39C12, #E67E22);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.8px;
  padding: 3px 7px;
  border-radius: 10px;
  text-transform: uppercase;
  box-shadow: 0 2px 6px rgba(230,126,34,0.4);
  z-index: 2;
}

/* Locked tool card — gray out content, keep badge vivid */
.tool-card.locked {
  cursor: pointer;
}
.tool-card.locked:hover {
  border-color: #F39C12;
  box-shadow: 0 4px 16px rgba(243,156,18,0.2);
  transform: translateY(-1px);
}
.tool-card.locked .tool-card-icon {
  filter: grayscale(1);
  opacity: 0.5;
}
.tool-card.locked .tool-card-name { color: var(--text-muted); }

/* Locked assistant card — gray header bg (overrides inline style), vivid badge */
.assistant-card.locked {
  cursor: pointer;
}
.assistant-card.locked:hover {
  box-shadow: 0 4px 16px rgba(243,156,18,0.2);
  transform: translateY(-1px);
}
.assistant-card.locked .assistant-card-header {
  background: #d0d0d0 !important; /* override inline headerColor */
}
.assistant-card.locked .assistant-card-name { color: #888; }
.assistant-card.locked .assistant-card-body  { color: #bbb; }

/* Pro badge on assistant cards */
.assistant-pro-badge {
  font-size: 10px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 12px;
  background: linear-gradient(135deg, #F39C12, #E67E22);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 3px;
}

/* ── PANEL BACK BAR ────────────────────────────────────────── */
.panel-back-bar {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: #fff;
  flex-shrink: 0;
}
.panel-back-btn {
  background: none;
  border: none;
  font-size: 15px;
  color: var(--primary);
  cursor: pointer;
  font-weight: 500;
  padding: 4px 0;
  white-space: nowrap;
}
.panel-back-btn:hover { opacity: 0.7; }
.panel-back-title {
  flex: 1;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  padding-right: 70px; /* balance back button width */
}

/* ── GENERIC SUB-PANEL (favorites / feedback / settings) ───── */
/* positioning & animation handled by .overlay-panel */
.sub-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.sub-panel-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  flex: 1;
}
.sub-panel-desc {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0;
}
.sub-panel-textarea {
  width: 100%;
  min-height: 140px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  background: var(--bg);
  color: var(--text);
  box-sizing: border-box;
}
.sub-panel-textarea:focus { outline: none; border-color: var(--primary); }
.sub-panel-field { display: flex; flex-direction: column; gap: 6px; }
.sub-panel-label { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.sub-panel-input {
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
}
.sub-panel-input:focus { outline: none; border-color: var(--primary); }
.sub-panel-submit-btn {
  padding: 14px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}
.sub-panel-submit-btn:hover { opacity: 0.9; }

/* ── UPGRADE MODAL ─────────────────────────────────────────── */
.upgrade-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.upgrade-modal-overlay.open { display: flex; }

.upgrade-modal {
  background: var(--white);
  border-radius: 20px;
  width: 100%;
  max-width: 400px;
  overflow: hidden;
  animation: popIn 0.25s ease;
  max-height: 90vh;
  overflow-y: auto;
}
@keyframes popIn {
  from { transform: scale(0.92); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.upgrade-hero {
  background: linear-gradient(135deg, #F39C12 0%, #E74C3C 100%);
  padding: 28px 24px 24px;
  text-align: center;
  color: #fff;
}
.upgrade-hero-icon { font-size: 40px; margin-bottom: 8px; }
.upgrade-hero-title { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.upgrade-hero-sub { font-size: 14px; opacity: 0.9; }

.upgrade-pricing {
  display: flex;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.price-card {
  flex: 1;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}
.price-card:hover, .price-card.selected {
  border-color: #F39C12;
  background: #FFF8EE;
}
.price-card .popular-tag {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: #F39C12;
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}
.price-card .price-amount { font-size: 22px; font-weight: 800; color: var(--text); }
.price-card .price-period { font-size: 11px; color: var(--text-muted); }
.price-card .price-save { font-size: 11px; color: var(--success); font-weight: 600; margin-top: 2px; }

.upgrade-features { padding: 16px 20px; }
.upgrade-features-title { font-size: 13px; font-weight: 700; color: var(--text-muted); margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.6px; }
.upgrade-feature-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  font-size: 14px;
  color: var(--text);
  border-bottom: 1px solid var(--bg);
}
.upgrade-feature-item:last-child { border-bottom: none; }
.feature-check { color: var(--success); font-size: 16px; flex-shrink: 0; }

.upgrade-actions { padding: 0 16px 20px; display: flex; flex-direction: column; gap: 8px; }
.upgrade-cta-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #F39C12, #E74C3C);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition);
  box-shadow: 0 4px 16px rgba(243,156,18,0.35);
}
.upgrade-cta-btn:hover { opacity: 0.92; transform: translateY(-1px); }
.upgrade-close-btn {
  width: 100%;
  padding: 11px;
  background: none;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}
.upgrade-close-btn:hover { background: var(--bg); color: var(--text); }
.upgrade-guarantee { text-align: center; font-size: 11px; color: var(--text-muted); padding: 0 16px 16px; }

/* ── FREE PLAN BANNER in Profile ───────────────────────────── */
.plan-banner {
  margin: 16px 20px 0;
  border-radius: var(--radius);
  overflow: hidden;
}
.plan-banner-free {
  background: linear-gradient(135deg, #FFF3CD, #FFF8E7);
  border: 1.5px solid #F39C12;
  padding: 16px;
}
.plan-banner-pro {
  background: linear-gradient(135deg, #E8F8EF, #D4F1DF);
  border: 1.5px solid var(--success);
  padding: 16px;
}
.plan-banner-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 4px;
}
.plan-banner-free .plan-banner-label { color: #E67E22; }
.plan-banner-pro .plan-banner-label  { color: var(--success); }
.plan-banner-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; line-height: 1.5; }
.plan-upgrade-btn {
  display: block;
  width: 100%;
  padding: 10px;
  background: linear-gradient(135deg, #F39C12, #E67E22);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: opacity var(--transition);
}
.plan-upgrade-btn:hover { opacity: 0.9; }
.plan-manage-btn {
  display: block;
  width: 100%;
  padding: 10px;
  background: none;
  border: 1.5px solid var(--success);
  color: var(--success);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: all var(--transition);
}
.plan-manage-btn:hover { background: #E8F8EF; }

/* Highlight on copy */
.copy-btn {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--text-muted);
  cursor: pointer;
  margin-left: 6px;
  transition: all var(--transition);
}
.copy-btn:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }

/* ============================================================
   NEW PROFILE HERO  (left-aligned, lavender background)
   ============================================================ */
.profile-hero-new {
  background: #EEF0FF;
  padding: 20px 20px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.profile-avatar-container-new { flex-shrink: 0; }
.profile-avatar-wrap-new {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #5B6EF7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  border: 3px solid #fff;
  box-shadow: 0 2px 10px rgba(74,144,217,0.3);
}
.profile-avatar-img-new {
  width: 64px; height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
  display: block;
}
.profile-hero-info { flex: 1; min-width: 0; }
.profile-name-new { font-size: 17px; font-weight: 700; color: var(--text); margin-bottom: 2px; }
.profile-email-new {
  font-size: 12px; color: var(--text-muted); margin-bottom: 8px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.profile-invite-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.invite-code-label { font-size: 11px; color: var(--text-muted); }
.invite-code-text {
  font-size: 13px; font-weight: 700; color: var(--primary);
  letter-spacing: 1.5px; font-family: "Courier New", monospace;
}
.invite-code-copy {
  font-size: 10px; padding: 2px 9px;
  border-radius: 10px; border: 1.5px solid var(--primary);
  color: var(--primary); background: transparent;
  cursor: pointer; font-weight: 700;
  transition: all var(--transition);
}
.invite-code-copy:hover { background: var(--primary); color: #fff; }

/* ── New plan card ────────────────────────────────────────── */
.plan-banner-outer { padding: 12px 16px 0; }
.plan-card {
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.plan-card-pro {
  background: linear-gradient(135deg, #1A6FE0, #4A90D9 60%, #5B6EF7);
  box-shadow: 0 4px 20px rgba(74,144,217,0.4);
}
.plan-card-free {
  background: linear-gradient(135deg, #F5F7FA, #ECF0F5);
  border: 1.5px solid var(--border);
}
.plan-card-left { flex: 1; min-width: 0; }
.plan-card-badge { font-size: 14px; font-weight: 800; letter-spacing: 0.2px; }
.plan-card-pro .plan-card-badge { color: #fff; }
.plan-card-free .plan-card-badge { color: var(--text); }
.plan-card-desc { font-size: 11px; margin-top: 2px; }
.plan-card-pro .plan-card-desc { color: rgba(255,255,255,0.78); }
.plan-card-free .plan-card-desc { color: var(--text-muted); }
.plan-card-btn {
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 12px; font-weight: 700;
  border: none; cursor: pointer;
  white-space: nowrap; flex-shrink: 0;
  transition: opacity var(--transition);
}
.plan-card-btn:hover { opacity: 0.85; }
.plan-card-pro .plan-card-btn {
  background: rgba(255,255,255,0.22);
  color: #fff;
  border: 1.5px solid rgba(255,255,255,0.45);
}
.plan-card-btn-upgrade {
  background: linear-gradient(135deg, #F39C12, #E67E22);
  color: #fff;
  box-shadow: 0 2px 8px rgba(230,126,34,0.35);
}

/* ── New profile menu groups ──────────────────────────────── */
.profile-menu-group {
  margin: 12px 16px 0;
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.profile-menu-item2 {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}
.profile-menu-item2:last-child { border-bottom: none; }
.profile-menu-item2:hover { background: var(--bg); }
.pmenu-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; flex-shrink: 0;
}
.pmenu-icon.orange { background: #FFF0E0; }
.pmenu-icon.blue   { background: #E8F4FD; }
.pmenu-icon.yellow { background: #FFFBE0; }
.pmenu-icon.green  { background: #E8F8EF; }
.pmenu-icon.gray   { background: var(--bg); }
.pmenu-icon.red    { background: #FDEDEC; }
.pmenu-text { flex: 1; min-width: 0; }
.pmenu-label { font-size: 15px; font-weight: 500; color: var(--text); }
.pmenu-sub { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.pmenu-arrow { font-size: 18px; color: #CCC; flex-shrink: 0; }
.pmenu-danger .pmenu-label { color: var(--danger); }

/* API key collapsible form */
.api-key-form-new { background: #FAFBFC; border-bottom: 1px solid var(--border); }
.api-key-form-new.collapsed { display: none; }
.api-key-form-inner { padding: 12px 16px 16px 64px; }
.api-key-form-new .api-key-desc {
  font-size: 12px; color: var(--text-muted); margin-bottom: 10px; line-height: 1.5;
}

.profile-footer-text {
  text-align: center; font-size: 12px; color: var(--text-muted);
  padding: 24px 0 12px;
}

/* ============================================================
   INVITE & EARN PANEL — layout handled by .overlay-panel
   ============================================================ */
#invite-panel {
  background: var(--bg); /* slightly off-white to match original */
}

.invite-user-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
}
.invite-panel-avatar-wrap { flex-shrink: 0; }
.invite-avatar-circle {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #5B6EF7);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; color: #fff;
}
.invite-avatar-photo {
  width: 56px; height: 56px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}
.invite-user-name { font-size: 17px; font-weight: 700; color: var(--text); }
.invite-user-id { font-size: 12px; color: var(--text-muted); margin-top: 4px; font-family: monospace; letter-spacing: 0.5px; }

/* 2×2 stats grid */
.referral-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
  margin: 16px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.referral-stat-item {
  background: var(--white);
  padding: 18px 12px;
  text-align: center;
}
.referral-stat-num {
  font-size: 30px; font-weight: 800;
  color: var(--primary); line-height: 1;
}
.referral-stat-label {
  font-size: 11px; color: var(--text-muted);
  margin-top: 6px; line-height: 1.3;
}

/* Invite buttons */
.invite-action-btns {
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.invite-btn {
  width: 100%; padding: 13px;
  border: none; border-radius: var(--radius);
  font-size: 15px; font-weight: 700;
  cursor: pointer; transition: all var(--transition);
}
.invite-btn-primary {
  background: linear-gradient(135deg, var(--primary), #5B6EF7);
  color: #fff;
  box-shadow: 0 4px 16px rgba(74,144,217,0.3);
}
.invite-btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.invite-btn-secondary {
  background: #E8F8EF;
  color: var(--success);
  border: 1.5px solid var(--success);
}
.invite-btn-secondary:hover { background: #D4F1DF; }

/* Instructions card */
.invite-instructions {
  margin: 16px;
  padding: 16px;
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.invite-instructions-title {
  font-size: 12px; font-weight: 700;
  color: var(--text-muted); margin-bottom: 10px;
  text-transform: uppercase; letter-spacing: 0.7px;
}
.invite-instructions-body {
  font-size: 13px; color: var(--text-muted); line-height: 1.7;
}
.invite-instructions-body strong { color: var(--primary); font-weight: 700; }
