/* Chat Scroll Container */
.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}
.chat-inner {
  width: 100%;
  max-width: 820px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-height: 100%;
}

/* Floating Scroll-to-Bottom Button */
.scroll-bottom-btn {
  position: absolute;
  bottom: 138px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: #282a2c;
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  z-index: 45;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  transition: opacity 0.2s, transform 0.22s var(--spring);
}
.scroll-bottom-btn.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

/* Welcome Screen (Exact Gemini App Hero) */
.welcome-screen {
  margin: auto 0;
  padding: 14px 4px;
  animation: fadeUp 0.45s var(--spring);
}
.welcome-hello {
  font-size: 38px;
  font-weight: 700;
  margin: 0 0 6px;
  line-height: 1.28;
  background: linear-gradient(90deg, #4285f4 0%, #9b72cb 48%, #d96570 92%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.welcome-sub-hero { font-size: 24px; font-weight: 500; color: #5f6368; margin: 0 0 22px; }

.gem-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 18px;
  scrollbar-width: none;
}
.gem-strip::-webkit-scrollbar { display: none; }
.gem-pill {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  transition: all 0.2s var(--spring);
}
.gem-pill:hover { background: var(--bg-surface-2); color: var(--text-primary); }
.gem-pill.active {
  background: rgba(76, 141, 246, 0.16);
  border-color: rgba(168, 199, 250, 0.5);
  color: var(--accent);
  font-weight: 600;
}

.suggestions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 11px;
}
.sugg-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 112px;
  transition: transform 0.22s var(--spring), background 0.2s, border-color 0.2s;
  animation: fadeUp 0.44s var(--spring) backwards;
}
.sugg-card:nth-child(2) { animation-delay: 0.05s; }
.sugg-card:nth-child(3) { animation-delay: 0.1s; }
.sugg-card:nth-child(4) { animation-delay: 0.15s; }
.sugg-card:hover { background: var(--bg-surface-2); border-color: rgba(168, 199, 250, 0.35); transform: translateY(-2px); }
.sugg-card:active { transform: scale(0.97); }
.sugg-text { font-size: 13.5px; line-height: 1.6; color: var(--text-primary); }
.sugg-icon-wrap {
  align-self: flex-end;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 10px;
}

/* Message Rows */
.msg-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  width: 100%;
  animation: fadeUp 0.26s var(--spring);
}
.msg-row.user { flex-direction: row-reverse; }

.avatar-user {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3c4043, #5f6368);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12.5px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 4px;
}

.msg-col {
  display: flex;
  flex-direction: column;
  max-width: 86%;
  min-width: 0;
}
.msg-row.user .msg-col { align-items: flex-start; }
.msg-row.assistant .msg-col { flex: 1; max-width: 100%; }

.msg-bubble {
  line-height: 1.82;
  font-size: 14.5px;
  word-break: break-word;
}
.msg-row.user .msg-bubble {
  background: var(--bg-surface-2);
  padding: 11px 17px;
  border-radius: 22px 6px 22px 22px;
  border: 1px solid var(--border);
}
.msg-row.assistant .msg-bubble { width: 100%; padding: 2px 0; }

/* User Message Attachments */
.msg-attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.msg-att-img {
  max-width: 220px;
  max-height: 190px;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  object-fit: cover;
  cursor: zoom-in;
}
.msg-att-chip {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  padding: 5px 10px;
  border-radius: 10px;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Streaming & Thinking */
.stream-cursor {
  display: inline-block;
  width: 7px;
  height: 16px;
  background: var(--accent);
  border-radius: 2px;
  margin-right: 4px;
  vertical-align: middle;
  animation: cursorBlink 0.9s infinite;
}
.thinking-wrap { display: flex; flex-direction: column; gap: 10px; width: 100%; padding-top: 4px; }
.thinking-label { font-size: 13px; color: var(--accent); display: flex; align-items: center; gap: 8px; font-weight: 500; }
.shimmer-bar {
  height: 11px;
  border-radius: 8px;
  background: linear-gradient(90deg, #1e1f20 25%, #2f333a 50%, #1e1f20 75%);
  background-size: 200% 100%;
  animation: shimmerMove 1.45s infinite linear;
}

/* Accordions (Thinking + SSH Operations) */
.accordion {
  background: #17181b;
  border: 1px solid var(--border);
  border-radius: 16px;
  margin: 4px 0 12px;
  overflow: hidden;
}
.acc-trigger {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-primary);
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 500;
}
.acc-left { display: flex; align-items: center; gap: 8px; color: var(--accent); }
.acc-body { max-height: 0; overflow: hidden; transition: max-height 0.34s var(--spring); border-top: 1px solid transparent; }
.accordion.open .acc-body { max-height: 1500px; border-top-color: var(--border); }
.accordion.open .acc-arrow { transform: rotate(180deg); }
.acc-arrow { transition: transform 0.25s var(--spring); color: var(--text-secondary); display: inline-flex; }

.thought-text {
  padding: 12px 14px;
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.75;
  white-space: pre-wrap;
  background: #141518;
}
.cmd-item { border-bottom: 1px solid rgba(255, 255, 255, 0.05); direction: ltr; text-align: left; }
.cmd-item:last-child { border-bottom: none; }
.cmd-header {
  background: #111214;
  padding: 7px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: #7fcfff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.cmd-out {
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: #c4d7f5;
  max-height: 240px;
  overflow-y: auto;
  white-space: pre-wrap;
  margin: 0;
  background: #0b0c0e;
}

/* Rich Markdown + Highlight.js */
.md-content p { margin: 0 0 11px; }
.md-content p:last-child { margin-bottom: 0; }
.md-content h1, .md-content h2, .md-content h3, .md-content h4 { margin: 16px 0 8px; font-weight: 700; color: #fff; }
.md-content h1 { font-size: 20px; }
.md-content h2 { font-size: 17.5px; }
.md-content h3 { font-size: 15.5px; }
.md-content ul, .md-content ol { padding-right: 22px; margin: 6px 0 12px; }
.md-content li { margin-bottom: 5px; }
.md-content hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.md-content a { color: var(--accent); text-decoration: none; border-bottom: 1px dashed rgba(168,199,250,0.4); }
.md-content blockquote {
  margin: 10px 0;
  padding: 9px 14px;
  border-right: 3px solid var(--accent);
  background: rgba(168, 199, 250, 0.07);
  border-radius: 8px;
  color: #cdd5df;
}
.md-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13px;
  display: block;
  overflow-x: auto;
}
.md-content th, .md-content td { border: 1px solid var(--border); padding: 8px 11px; text-align: right; }
.md-content th { background: rgba(255, 255, 255, 0.06); font-weight: 600; }

.code-wrap {
  margin: 12px 0;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  background: #0d0e10;
  direction: ltr;
  text-align: left;
}
.code-bar {
  background: #1a1c20;
  padding: 6px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-secondary);
  font-family: ui-monospace, monospace;
}
.code-bar-actions { display: flex; gap: 6px; align-items: center; }
.code-action-btn {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 8px;
  font-family: 'Vazirmatn', sans-serif;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background 0.15s, border-color 0.15s;
}
.code-action-btn:hover { background: rgba(168, 199, 250, 0.18); border-color: rgba(168, 199, 250, 0.45); }
.code-action-btn.canvas-btn { background: rgba(155, 114, 203, 0.22); border-color: rgba(197, 138, 249, 0.45); color: #e2c5ff; }
.md-content pre {
  margin: 0;
  padding: 13px 15px;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.68;
  background: #0d0e10 !important;
}
.md-content pre code { background: transparent !important; padding: 0 !important; font-family: inherit; }
.md-content code.inline-code, .md-content :not(pre) > code {
  background: #282a2c;
  padding: 2px 6px;
  border-radius: 6px;
  font-family: ui-monospace, monospace;
  font-size: 12.5px;
  direction: ltr;
  display: inline-block;
  color: #a8c7fa;
}

/* Error & Upgrade Notice */
.upgrade-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  background: rgba(129, 201, 149, 0.12);
  color: var(--success);
  border: 1px solid rgba(129, 201, 149, 0.32);
  padding: 4px 11px;
  border-radius: var(--radius-pill);
  margin-bottom: 9px;
}
.error-card {
  background: rgba(242, 139, 130, 0.08);
  border: 1px solid rgba(242, 139, 130, 0.32);
  border-radius: 16px;
  padding: 13px 15px;
}
.error-title { color: var(--danger); font-weight: 600; font-size: 13.5px; margin-bottom: 6px; display: flex; align-items: center; gap: 7px; }
.error-detail {
  direction: ltr;
  text-align: left;
  font-family: ui-monospace, monospace;
  font-size: 11.5px;
  color: #d7a6a1;
  background: rgba(0, 0, 0, 0.3);
  padding: 9px 11px;
  border-radius: 10px;
  overflow-x: auto;
  white-space: pre-wrap;
}

/* Message Action Row (Clean, Outside Bubble) */
.msg-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  margin-top: 6px;
  opacity: 0.72;
  transition: opacity 0.2s;
}
.msg-row:hover .msg-actions { opacity: 1; }
.msg-act-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 12px;
  padding: 5px 8px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background 0.15s, color 0.15s;
}
.msg-act-btn:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.msg-model-tag { font-size: 11px; color: var(--text-muted); margin-right: 6px; direction: ltr; }

/* Gemini App Floating Composer */
.composer-wrap {
  padding: 8px 12px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: linear-gradient(to top, var(--bg-main) 80%, transparent);
  position: relative;
}
.composer-inner {
  width: 100%;
  max-width: 820px;
  background: #1e1f20;
  border: 1px solid var(--border-strong);
  border-radius: 28px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.22s, box-shadow 0.22s, background 0.22s;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.42);
  position: relative;
}
.composer-inner:focus-within {
  background: #222426;
  border-color: rgba(168, 199, 250, 0.58);
  box-shadow: 0 0 0 3px rgba(76, 141, 246, 0.14), 0 10px 32px rgba(0, 0, 0, 0.48);
}
.composer-inner.dragover {
  border-color: var(--accent-strong);
  background: rgba(76, 141, 246, 0.12);
}

/* Attach Popover Menu */
.attach-menu {
  display: none;
  position: absolute;
  bottom: calc(100% + 10px);
  right: 8px;
  background: #232528;
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  padding: 6px;
  min-width: 220px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.65);
  z-index: 95;
  animation: modalPop 0.2s var(--spring);
}
.attach-menu.open { display: flex; flex-direction: column; gap: 2px; }
.attach-menu-item {
  background: transparent;
  border: none;
  color: var(--text-primary);
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: right;
  transition: background 0.15s;
}
.attach-menu-item:hover { background: rgba(255, 255, 255, 0.08); }

.attach-preview-bar { display: none; flex-wrap: wrap; gap: 8px; padding: 4px 4px 2px; }
.attach-preview-bar.has-items { display: flex; }
.att-chip {
  background: #2b2d30;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 6px 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  max-width: 220px;
  animation: modalPop 0.2s var(--spring);
}
.att-chip img { width: 32px; height: 32px; border-radius: 6px; object-fit: cover; }
.att-chip-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-remove {
  background: rgba(0, 0, 0, 0.55);
  border: none;
  color: #fff;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Live Audio Equalizer Recording Bar */
.recording-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  background: rgba(242, 139, 130, 0.11);
  border: 1px solid rgba(242, 139, 130, 0.34);
  border-radius: 18px;
  padding: 8px 12px;
  gap: 10px;
}
.recording-bar.active { display: flex; }
.rec-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
#audioVizCanvas { width: 96px; height: 28px; border-radius: 6px; }
.rec-time { font-size: 12.5px; color: var(--danger); font-weight: 700; font-family: ui-monospace, monospace; direction: ltr; }

.composer-textarea {
  width: 100%;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 14.5px;
  resize: none;
  max-height: 165px;
  min-height: 28px;
  padding: 6px 8px;
  outline: none;
  line-height: 1.6;
}
.composer-textarea::placeholder { color: #7e8690; }

.composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.composer-tools-right, .composer-tools-left { display: flex; align-items: center; gap: 4px; }

.tool-pill {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 6px 11px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.18s;
  white-space: nowrap;
}
.tool-pill:hover { background: rgba(255, 255, 255, 0.06); color: var(--text-primary); }
.tool-pill.active {
  background: rgba(168, 199, 250, 0.16);
  border-color: rgba(168, 199, 250, 0.48);
  color: var(--accent);
  font-weight: 600;
}
.tool-pill.coder.active {
  background: rgba(197, 138, 249, 0.18);
  border-color: rgba(197, 138, 249, 0.48);
  color: var(--purple);
}

.mic-btn.recording {
  background: rgba(242, 139, 130, 0.22);
  color: var(--danger);
  animation: recPulse 1.3s infinite;
}

.send-btn {
  background: var(--accent-strong);
  color: #131314;
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s var(--spring), background 0.2s;
}
.send-btn:hover { transform: scale(1.06); background: #6ea8fe; }
.send-btn:active { transform: scale(0.92); }
.send-btn.empty { background: #333537; color: #8e918f; }
.send-btn.stop-mode { background: var(--danger); color: #131314; }

@media (max-width: 600px) {
  .welcome-hello { font-size: 30px; }
  .welcome-sub-hero { font-size: 19px; }
  .msg-col { max-width: 90%; }
  .tool-pill span.hide-xs { display: none; }
}
