/* =============================================================
   components.css — every visual widget.
   ============================================================= */

/* --- Wordmark --- */
.wordmark {
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.02em;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.wordmark .fetch {
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-title {
  font-size: clamp(34px, 6vw, 56px);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0;
}
.hero-title .fetch {
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-sub { color: var(--text-soft); font-size: 16px; margin: 6px 0 0; }

/* --- Mascot --- */
.mascot { width: 22px; height: 22px; flex: none; }
.hero-mascot { width: 76px; height: 76px; margin-bottom: 4px; }

/* --- Search bar --- */
.searchbar {
  display: flex;
  align-items: center;
  background: var(--bg-elevated);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-pill);
  padding: 6px 6px 6px 20px;
  box-shadow: var(--shadow);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.searchbar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow);
}
.searchbar input[type="text"] {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 17px;
  color: var(--text);
  font-family: inherit;
}
.searchbar input::placeholder { color: var(--text-faint); }

/* --- Fetch button (Dogpile-style "Fetch" not "Search") --- */
.btn-fetch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  cursor: pointer;
  background: var(--brand-gradient);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  padding: 12px 22px;
  border-radius: var(--radius-pill);
  font-family: inherit;
  transition: transform var(--dur) var(--ease), filter var(--dur) var(--ease);
}
.btn-fetch:hover { transform: translateY(-1px); filter: brightness(1.05); }
.btn-fetch:active { transform: translateY(0); }
.btn-fetch .mascot { filter: drop-shadow(0 1px 1px rgba(0,0,0,0.25)); }

/* --- Generic buttons --- */
.btn {
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  border-radius: var(--radius-pill);
  padding: 9px 16px;
  border: 1.5px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.btn:hover { background: var(--bg-sunk); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--bg-sunk); }
.btn-primary {
  background: var(--brand-gradient);
  color: #fff;
  border-color: transparent;
}
.btn-primary:hover { filter: brightness(1.05); background: var(--brand-gradient); }

/* Chat-about-this: a light accent pill, not a heavy gradient block.
   Matches the calm outline style of the other buttons. */
.btn-chat {
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-color: transparent;
}
.btn-chat:hover { background: var(--accent-soft); filter: brightness(0.97); }
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--bg-sunk);
  color: var(--text-faint);
}

/* --- Advanced toggle --- */
.adv-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 14px auto 0;
  color: var(--text-soft);
  font-size: 13px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}
.adv-toggle:hover { color: var(--accent-ink); }
.adv-toggle .chev { transition: transform var(--dur) var(--ease); }
.adv-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }

/* --- Advanced panel --- */
.adv-panel {
  max-width: 720px;
  margin: 14px auto 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  text-align: left;
}
.adv-panel[hidden] { display: none; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.field input, .field select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
}
.field.check { display: flex; align-items: center; gap: 8px; }
.field.check label { margin: 0; text-transform: none; letter-spacing: 0; font-size: 13px; }
.field.check input { width: auto; }

/* --- Tabs --- */
.tab {
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  font-size: 15px;
  color: var(--text-soft);
  padding: 10px 16px;
  border-bottom: 2.5px solid transparent;
  margin-bottom: -1px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent-ink); border-bottom-color: var(--accent); }
.tab .count {
  font-size: 11px;
  background: var(--bg-sunk);
  color: var(--text-soft);
  border-radius: var(--radius-pill);
  padding: 1px 7px;
}
.tab-panel[hidden] { display: none; }

/* --- Answer (TL;DR) card --- */
.tldr {
  background: var(--bg-sunk);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 24px;
}
.tldr .tldr-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin-bottom: 8px;
}
.tldr .tldr-foot { margin-top: 14px; display: flex; align-items: center; gap: 10px; }

/* --- Mistral SVG icons (TL;DR head, sidebar head) --- */
.mistral-icon { width: 18px; height: 18px; display: block; flex: none; }

/* --- Icon buttons (sidebar toggles) --- */
.btn-icon {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  color: var(--text-soft);
  padding: 6px 9px;
  border-radius: var(--radius-sm);
  font-family: inherit;
}
.btn-icon:hover { background: var(--bg-sunk); color: var(--text); }

/* --- Sidebar history items --- */
.hist-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text-soft);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hist-item:hover { background: var(--bg-elevated); color: var(--text); }
.hist-empty { color: var(--text-faint); font-size: 13px; padding: 8px 10px; margin: 0; }
.sidebar-action { justify-content: flex-start; font-size: 13px; padding: 8px 10px; text-align: left; }
.side-flash { font-size: 12.5px; color: #2e9e5b; padding: 6px 10px; }

/* --- Markdown rendering (TL;DR + chat bubbles) --- */
.md { font-size: 16px; }
.md p { margin: 0 0 10px; }
.md p:last-child { margin-bottom: 0; }
.md a { color: var(--link); }
.md ul, .md ol { margin: 6px 0 10px; padding-left: 20px; }
.md li { margin: 2px 0; }
.md code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--bg-sunk);
  padding: 1px 5px;
  border-radius: 5px;
}
.md pre {
  background: var(--bg-sunk);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  overflow-x: auto;
}
.md pre code { background: none; padding: 0; }
.md strong { font-weight: 700; }
.md h1, .md h2, .md h3 { font-size: 1.05em; margin: 12px 0 6px; }
.bubble .md { font-size: 15px; }

/* --- Result cards (web) --- */
.result {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.result:last-child { border-bottom: none; }
.result .r-top { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.result .favicon { width: 16px; height: 16px; border-radius: 4px; flex: none; }
.result .r-url { font-size: 12px; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result .r-title { font-size: 18px; font-weight: 700; margin: 0 0 4px; }
.result .r-title a { color: var(--link); }
.result .r-snippet {
  color: var(--text-soft);
  font-size: 14.5px;
  margin: 0;
  /* Trim to 2 lines — this text is grounding for the AI, not meant to be
     read in full by humans. The model still receives the untruncated content. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.result .r-score {
  font-size: 11px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  float: right;
}

/* --- Image cards --- */
.img-card {
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-sunk);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.img-card img { width: 100%; height: 140px; object-fit: cover; display: block; }
.img-card .cap { padding: 8px 10px; font-size: 12px; color: var(--text-soft); }

/* --- Chat bubbles --- */
.bubble {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 15px;
}
.bubble.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.bubble.bot  { align-self: flex-start; background: var(--bg-elevated); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.chat-input-row textarea {
  flex: 1;
  resize: none;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 11px 14px;
  font-family: inherit;
  font-size: 15px;
  background: var(--bg-elevated);
  color: var(--text);
  outline: none;
}
.chat-input-row textarea:focus { border-color: var(--accent); }

/* --- Banners --- */
.banner {
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14px;
  margin-bottom: 18px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.banner.warn { background: var(--warn-bg); color: var(--warn-ink); border: 1px solid var(--warn-line); }
.banner.err  { background: var(--err-bg); color: var(--err-ink); border: 1px solid var(--err-ink); }
.banner a { color: inherit; text-decoration: underline; }

/* --- Loading dots --- */
.loader { display: inline-flex; gap: 5px; align-items: center; }
.loader span {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  animation: bounce 1s infinite var(--ease);
}
.loader span:nth-child(2) { animation-delay: 0.15s; }
.loader span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%,100%{ transform: translateY(0); opacity: .5;} 50%{ transform: translateY(-6px); opacity: 1;} }


/* --- Settings --- */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}
.card h2 { margin: 0 0 4px; font-size: 18px; }
.card .hint { color: var(--text-soft); font-size: 13.5px; margin: 0 0 16px; }
.card .hint a { color: var(--link); }
.input-row { display: flex; gap: 10px; align-items: center; }
.input-row input {
  flex: 1;
  padding: 11px 13px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 13.5px;
  background: var(--bg);
  color: var(--text);
}
.saved-tag { font-size: 12.5px; color: var(--text-faint); margin-top: 8px; }
.saved-tag.ok { color: #2e7d32; }
