@import url('https://fonts.googleapis.com/css2?family=Inter:ital,wght@0,400;0,500;0,600;0,700;0,800;1,400&display=swap');

:root {
  --bg: #F8FAFC;
  --panel: #FFFFFF;
  --sidebar-bg: #111315;
  --ink: #111827;
  --muted: #6B7280;
  --muted-light: #9CA3AF;
  --border: #ECEFF3;
  --border-mid: #E2E8F0;
  --accent: #C2542B;
  --accent-soft: #FEF3EC;
  --accent-dark: #A84524;
  --good: #059669;
  --good-soft: #ECFDF5;
  --mid: #D97706;
  --mid-soft: #FFFBEB;
  --low: #6B7280;
  --low-soft: #F9FAFB;
  --radius: 18px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.03);
  --shadow: 0 2px 10px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 24px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 48px rgba(0,0,0,0.14);
  font-size: 16px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}

.layout {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--sidebar-bg);
  color: #fff;
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #2E3035 transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: #2E3035; border-radius: 999px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: #3D4147; }

/* ---------- Auth wall ---------- */
.auth-wall {
  position: fixed;
  inset: 0;
  background: var(--sidebar-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.auth-card {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.auth-tagline {
  color: rgba(255,255,255,0.55);
  font-size: 0.9rem;
}
.auth-sign-in-btn {
  margin-top: 8px;
  padding: 10px 28px;
  font-size: 0.95rem;
}

/* Clerk loads the Google provider logo from its image host, which can fail and
   show a broken-image glyph. Replace it with a self-contained inline logo so it
   never depends on an external request. This is purely cosmetic — it only
   restyles Clerk's rendered icon and cannot affect auth/component loading.
   Broad [class*=...] match survives Clerk's hashed class-name suffixes. */
[class*="socialButtonsProviderIcon"],
.cl-socialButtonsBlockButton img,
.cl-socialButtonsIconButton img {
  content: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgdmlld0JveD0iMCAwIDQ4IDQ4Ij48cGF0aCBmaWxsPSIjRkZDMTA3IiBkPSJNNDMuNjExIDIwLjA4M0g0MlYyMEgyNHY4aDExLjMwM2MtMS42NDkgNC42NTctNi4wOCA4LTExLjMwMyA4LTYuNjI3IDAtMTItNS4zNzMtMTItMTJzNS4zNzMtMTIgMTItMTJjMy4wNTkgMCA1Ljg0MiAxLjE1NCA3Ljk2MSAzLjAzOWw1LjY1Ny01LjY1N0MzNC4wNDYgNi4wNTMgMjkuMjY4IDQgMjQgNCAxMi45NTUgNCA0IDEyLjk1NSA0IDI0czguOTU1IDIwIDIwIDIwIDIwLTguOTU1IDIwLTIwYzAtMS4zNDEtLjEzOC0yLjY1LS4zODktMy45MTd6Ii8+PHBhdGggZmlsbD0iI0ZGM0QwMCIgZD0iTTYuMzA2IDE0LjY5MWw2LjU3MSA0LjgxOUMxNC42NTUgMTUuMTA4IDE4Ljk2MSAxMiAyNCAxMmMzLjA1OSAwIDUuODQyIDEuMTU0IDcuOTYxIDMuMDM5bDUuNjU3LTUuNjU3QzM0LjA0NiA2LjA1MyAyOS4yNjggNCAyNCA0IDE2LjMxOCA0IDkuNjU2IDguMzM3IDYuMzA2IDE0LjY5MXoiLz48cGF0aCBmaWxsPSIjNENBRjUwIiBkPSJNMjQgNDRjNS4xNjYgMCA5Ljg2LTEuOTc3IDEzLjQwOS01LjE5MmwtNi4xOS01LjIzOEMyOS4yMTEgMzUuMDkxIDI2LjcxNSAzNiAyNCAzNmMtNS4yMDIgMC05LjYxOS0zLjMxNy0xMS4yODMtNy45NDZsLTYuNTIyIDUuMDI1QzkuNTA1IDM5LjU1NiAxNi4yMjcgNDQgMjQgNDR6Ii8+PHBhdGggZmlsbD0iIzE5NzZEMiIgZD0iTTQzLjYxMSAyMC4wODNINDJWMjBIMjR2OGgxMS4zMDNjLS43OTIgMi4yMzctMi4yMzEgNC4xNjYtNC4wODcgNS41NzEuMDAxLS4wMDEuMDAyLS4wMDEuMDAzLS4wMDJsNi4xOSA1LjIzOEMzNi45NzEgMzkuMjA1IDQ0IDM0IDQ0IDI0YzAtMS4zNDEtLjEzOC0yLjY1LS4zODktMy45MTd6Ii8+PC9zdmc+") !important;
  width: 20px !important;
  height: 20px !important;
  object-fit: contain !important;
}

/* ---------- Sidebar token wallet ---------- */
.token-box {
  margin-top: auto;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
}
.token-icon { font-size: 0.82rem; line-height: 1; }
#token-count { font-size: 0.82rem; font-weight: 700; color: #fff; }
.token-label { font-size: 0.75rem; color: rgba(255,255,255,0.45); flex: 1; }
.token-hint { display: none; }
.token-add-btn {
  flex-shrink: 0;
  background: rgba(255,255,255,0.1);
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.token-add-btn:hover { background: rgba(255,255,255,0.18); color: #fff; }
.token-free-btn {
  width: 100%;
  margin-top: 12px;
  padding: 8px;
  background: transparent;
  border: 1px dashed rgba(0,0,0,0.15);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.75rem;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s;
}
.token-free-btn:hover { background: var(--bg); }

/* ---------- Token purchase modal ---------- */
.token-modal {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center;
}
.token-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
}
.token-modal-panel {
  position: relative; z-index: 1;
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 90%; max-width: 480px;
  overflow: hidden;
}
.token-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 1rem;
}
.token-modal-body { padding: 20px; }
.token-packs { display: flex; flex-direction: column; gap: 10px; }
.token-pack {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  border: 2px solid var(--border-mid);
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: pointer; text-align: left;
  position: relative;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.token-pack:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.token-pack-featured { border-color: var(--accent); background: var(--accent-soft); }
.pack-badge {
  position: absolute; top: -9px; left: 14px;
  background: var(--accent); color: #fff;
  font-size: 0.68rem; font-weight: 600;
  padding: 2px 8px; border-radius: 20px; letter-spacing: 0.02em;
}
.pack-tokens { font-weight: 700; font-size: 1rem; flex: 1; }
.pack-searches { font-size: 0.8rem; color: var(--muted); }
.pack-price { font-weight: 700; font-size: 1.05rem; color: var(--accent); margin-left: auto; }

/* ---------- Sidebar user row ---------- */
.user-row {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
}
#user-button-mount {
  flex-shrink: 0;
}
.user-email {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.45);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logo {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #fff;
  padding: 6px 10px 18px;
}
.logo span { color: var(--accent); }

.sidebar-heading {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.3px;
  color: #374151;
  padding: 14px 10px 6px;
}

/* New analysis button — override .btn defaults */
#new-analysis-btn.btn {
  display: flex;
  align-items: center;
  width: 100%;
  margin: 0 0 6px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.83rem;
  font-weight: 500;
  color: #9CA3AF;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.08);
  cursor: pointer;
  transition: all 0.15s;
  justify-content: flex-start;
  letter-spacing: -0.01em;
}
#new-analysis-btn.btn:hover {
  background: rgba(255,255,255,0.06);
  color: #E5E7EB;
  border-color: rgba(255,255,255,0.14);
  transform: none;
  box-shadow: none;
}

.history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow-y: auto;
}

.history-list li {
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  color: #6B7280;
  line-height: 1.35;
  transition: all 0.12s;
}
.history-list li:hover { background: rgba(255,255,255,0.06); color: #D1D5DB; }
.history-list li.active { background: rgba(194,84,43,0.18); color: #FCA68C; }
.history-list .count {
  display: block;
  font-size: 0.7rem;
  font-weight: 400;
  color: #374151;
  margin-top: 1px;
}
.history-empty { color: #374151; font-size: 0.8rem; padding: 4px 10px; }

/* ---------- Main ---------- */
.main {
  padding: 48px clamp(24px, 5vw, 72px);
  max-width: 1100px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.step-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--accent);
  margin-bottom: 10px;
}

h2 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--ink);
  margin-bottom: 8px;
  line-height: 1.3;
}

.muted { color: var(--muted); line-height: 1.65; font-size: 0.9rem; }
.hidden { display: none !important; }

/* ---------- Form ---------- */
label {
  display: block;
  margin: 20px 0 7px;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}

input[type="text"], textarea {
  width: 100%;
  padding: 11px 15px;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.92rem;
  background: var(--panel);
  color: var(--ink);
  resize: vertical;
  transition: border-color 0.15s, box-shadow 0.15s;
  line-height: 1.6;
}
input[type="text"]::placeholder, textarea::placeholder { color: var(--muted-light); }
input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(194,84,43,0.1);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: 9px;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s;
  letter-spacing: -0.01em;
  margin-top: 20px;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.38; cursor: not-allowed; transform: none !important; box-shadow: none !important; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover:not(:disabled) {
  background: #1F2937;
  box-shadow: 0 4px 14px rgba(17,24,39,0.22);
  transform: translateY(-1px);
}
.btn-secondary {
  background: rgba(255,255,255,0.07);
  color: #D1D5DB;
  border: 1px solid rgba(255,255,255,0.1);
}
.btn-secondary:hover:not(:disabled) {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.18);
}
.full-width { width: 100%; margin-top: 0; }

/* ---------- Term chips ---------- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 20px 0 8px;
}

.chip {
  padding: 7px 16px;
  border-radius: 999px;
  border: 1px solid var(--border-mid);
  background: var(--panel);
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.14s;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.chip:hover { border-color: var(--ink); }
.chip.selected { background: var(--ink); border-color: var(--ink); color: #fff; }

.terms-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
}

/* ---------- Results grid ---------- */
.results-grid {
  position: relative;
  min-height: 1px;
}

.result-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
  cursor: default;
}
.result-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* ---------- More search panel ---------- */
.more-search-panel { margin-top: 24px; }

.custom-term-row {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  align-items: center;
}
.custom-term-row input { flex: 1; margin: 0; }
.custom-term-row .btn { margin-top: 0; white-space: nowrap; }

.chip-removable {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--ink);
  border: 1px solid var(--ink);
  color: #fff;
  border-radius: 999px;
  padding: 6px 10px 6px 14px;
  font-family: inherit;
  font-size: 0.83rem;
  font-weight: 500;
}
.chip-rm {
  background: none;
  border: none;
  color: inherit;
  opacity: 0.6;
  cursor: pointer;
  font-size: 1em;
  line-height: 1;
  padding: 0 2px;
  font-family: inherit;
}
.chip-rm:hover { opacity: 1; }

.chip-used {
  padding: 5px 13px;
  border-radius: 999px;
  border: 1.5px solid var(--border-mid);
  background: var(--bg);
  color: var(--muted-light);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: default;
  user-select: none;
}

.searched-terms-section { margin-bottom: 14px; }
.searched-terms-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted-light);
  margin-bottom: 8px;
}

.new-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--good-soft);
  color: var(--good);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ---------- Result card — header ---------- */
.result-top {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.result-icon {
  width: 50px;
  height: 50px;
  border-radius: 12px;
  flex-shrink: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  object-fit: cover;
}

.result-name {
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.3;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.result-dev { font-size: 0.77rem; color: var(--muted); margin-top: 2px; }
.result-meta { font-size: 0.74rem; color: var(--muted-light); margin-top: 3px; }

/* ---------- Score pill + save button wrapper ---------- */
.result-top-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

.score-badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  padding: 4px 11px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: -0.01em;
}
.score-high { background: var(--good-soft); color: var(--good); }
.score-mid  { background: var(--mid-soft);  color: var(--mid); }
.score-low  { background: var(--low-soft);  color: var(--low); border: 1px solid var(--border); }

/* ---------- Screenshots ---------- */
.screenshots {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-mid) transparent;
  padding-bottom: 2px;
}
.screenshots img {
  height: 130px;
  width: auto;
  border-radius: 10px;
  flex-shrink: 0;
  object-fit: cover;
  background: var(--bg);
}

/* ---------- Score bar ---------- */
.score-bar { height: 3px; border-radius: 99px; background: var(--border); overflow: hidden; }
.score-bar-fill { height: 100%; border-radius: 99px; background: var(--accent); }

/* ---------- Feature tags ---------- */
.features {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.features li {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg);
  color: var(--muted);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.73rem;
  font-weight: 500;
}
.features li.feat-shared {
  background: var(--good-soft);
  color: var(--good);
  cursor: pointer;
}
.features li.feat-shared:hover { filter: brightness(0.93); }
.features li.feat-unique {
  background: #FEF2F2;
  color: #DC2626;
  cursor: pointer;
}
.features li.feat-unique:hover { filter: brightness(0.93); }
.feat-icon {
  font-size: 0.65rem;
  font-weight: 700;
  flex-shrink: 0;
}

.result-summary {
  font-size: 0.83rem;
  color: var(--muted);
  line-height: 1.6;
}

.store-link {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  margin-top: auto;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  transition: opacity 0.14s;
}
.store-link:hover { opacity: 0.75; }

/* ---------- Loading ---------- */
.loading {
  position: fixed;
  inset: 0;
  background: rgba(248,250,252,0.8);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 50;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 2.5px solid var(--border-mid);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Error banner ---------- */
.error-banner {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 0.84rem;
  font-weight: 500;
  max-width: 480px;
  z-index: 60;
  box-shadow: 0 8px 32px rgba(0,0,0,0.22);
}
.error-banner.success-banner { background: #059669; }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { height: auto; position: static; }
}

/* ---------- Tabs ---------- */
.tab-bar {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  gap: 0;
}

.tab-btn {
  padding: 10px 20px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.14s;
  letter-spacing: -0.01em;
}
.tab-btn:hover { color: var(--ink); }
.tab-btn.active { color: var(--ink); border-bottom-color: var(--ink); }

/* ---------- Features tab ---------- */
.tab-intro { margin-bottom: 20px; font-size: 0.87rem; }

.features-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 24px;
}

/* ---------- Feature categories ---------- */
.feat-category {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 8px;
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s;
}
.feat-category:hover { box-shadow: var(--shadow); }

.feat-cat-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.87rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
  letter-spacing: -0.01em;
}
.feat-cat-header:hover { background: var(--bg); }
.feat-cat-header.open { background: var(--bg); }

.feat-cat-name { flex: 1; }

.feat-cat-badge {
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 0.72rem;
  font-weight: 600;
}

.feat-cat-arrow {
  color: var(--muted-light);
  font-size: 0.95rem;
  display: inline-block;
  transition: transform 0.2s;
}

.feat-cat-body {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border);
}

.feat-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.feat-chips-row + .feat-show-more { margin-top: 10px; }
.feat-rare { margin-top: 8px; }

.feat-show-more {
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.79rem;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
  display: block;
}
.feat-show-more:hover { text-decoration: underline; }

.feat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid var(--border-mid);
  background: var(--panel);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.feat-chip:hover { border-color: var(--ink); }
.feat-chip.selected { background: var(--ink); border-color: var(--ink); color: #fff; }
.feat-count {
  background: rgba(0,0,0,0.08);
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 0.74em;
  font-weight: 700;
}
.feat-chip.selected .feat-count { background: rgba(255,255,255,0.2); }
.feat-chip.feat-incompatible { display: none; }
.feat-category.feat-incompatible { display: none; }

.categorize-prompt { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 16px 0; }
.categorize-btn { font-size: 0.875rem; background: var(--ink); color: #fff; border: none; border-radius: var(--radius); padding: 10px 18px; cursor: pointer; font-weight: 500; }
.categorize-btn:hover { background: #1F2937; }
.categorize-note { font-size: 0.75rem; color: var(--muted); margin: 0; }

.features-msg { font-size: 0.87rem; color: var(--muted); margin-bottom: 16px; }

/* ---------- Chat FAB — glassmorphism ---------- */
.chat-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: rgba(17,19,21,0.84);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.13);
  border-radius: 999px;
  padding: 11px 22px;
  font-family: inherit;
  font-size: 0.87rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 24px rgba(0,0,0,0.2), 0 1px 4px rgba(0,0,0,0.1);
  z-index: 40;
  transition: all 0.2s ease;
  letter-spacing: -0.01em;
}
.chat-fab:hover {
  background: rgba(17,19,21,0.96);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.28);
}

/* ---------- Chat panel ---------- */
.chat-panel {
  position: fixed;
  bottom: 84px;
  right: 28px;
  width: 370px;
  height: 500px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  z-index: 45;
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.88rem;
  flex-shrink: 0;
  letter-spacing: -0.02em;
}

.chat-close {
  background: none;
  border: none;
  font-size: 1rem;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 7px;
  border-radius: 6px;
  transition: all 0.12s;
}
.chat-close:hover { color: var(--ink); background: var(--bg); }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.chat-welcome {
  font-size: 0.83rem;
  color: var(--muted);
  text-align: center;
  padding: 8px 4px;
  line-height: 1.6;
}

.chat-msg {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.85rem;
  line-height: 1.55;
  max-width: 88%;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-msg.user {
  background: var(--ink);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.chat-msg.assistant {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--ink);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.chat-app-link {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  font-weight: 500;
}
.chat-app-link:hover { color: var(--accent-dark); }


.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-input-row input { flex: 1; margin: 0; }
.chat-input-row .btn { margin-top: 0; }
.chat-token-note { font-size: 0.7rem; color: rgba(255,255,255,0.35); margin: 4px 0 0; text-align: right; }

/* ---------- Overview / novelty panel ---------- */
.overview-panel { margin-bottom: 20px; }

.novelty-range-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.novelty-title {
  font-size: 0.67rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--muted);
}

.novelty-header-right {
  display: flex;
  align-items: baseline;
  gap: 7px;
  flex-wrap: wrap;
}

.novelty-score-num {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.04em;
  line-height: 1;
}

.novelty-sep { color: var(--muted-light); font-size: 1rem; }

.novelty-label-text {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.02em;
}

/* Track */
.novelty-track-wrap {
  position: relative;
  padding: 5px 0;
  margin-bottom: 8px;
}

.novelty-track {
  height: 10px;
  display: flex;
  border-radius: 999px;
  overflow: hidden;
}

.nz { flex: 1; opacity: 0.15; transition: opacity 0.35s; }
.nz.nz-active { opacity: 1; }
.nz-saturated     { background: #EF4444; }
.nz-crowded       { background: #F97316; }
.nz-competitive   { background: #EAB308; }
.nz-differentiated{ background: #84CC16; }
.nz-novel         { background: #22C55E; }

/* Marker: vertical line + circle handle */
.novelty-marker {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: var(--ink);
  border-radius: 1px;
  transform: translateX(-50%);
  transition: left 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 1;
}
.novelty-marker::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  border: 2.5px solid var(--ink);
  box-shadow: var(--shadow-sm);
}

/* Zone labels */
.novelty-zone-labels {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  margin-bottom: 24px;
}
.novelty-zone-labels span {
  font-size: 0.66rem;
  color: var(--muted-light);
  text-align: center;
  line-height: 1.3;
}

.competition-tag {
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 0.77rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.comp-low      { background: var(--good-soft); color: var(--good); }
.comp-moderate { background: var(--mid-soft);  color: var(--mid); }
.comp-high     { background: #FEF2F2; color: #DC2626; }

.analysis-body { display: flex; flex-direction: column; gap: 16px; }

.analysis-overview {
  font-size: 0.93rem;
  line-height: 1.7;
  color: var(--ink);
}

.analysis-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 640px) { .analysis-cols { grid-template-columns: 1fr; } }

.analysis-section { display: flex; flex-direction: column; gap: 8px; }

.analysis-section-title {
  font-size: 0.67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--muted);
}

.analysis-list { display: flex; flex-direction: column; gap: 6px; }

.analysis-item {
  font-size: 0.84rem;
  line-height: 1.55;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--bg);
  border-left: 3px solid var(--border-mid);
  color: var(--ink);
}
.analysis-item.threat      { border-left-color: #EF4444; background: #FEF2F2; color: #7F1D1D; }
.analysis-item.opportunity { border-left-color: var(--good); background: var(--good-soft); color: #064E3B; }

.analysis-verdict {
  font-size: 0.87rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: 16px;
  line-height: 1.65;
}


/* ---------- Results header ---------- */
.sort-row {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
  margin-top: 0;
  gap: 10px;
  margin-top: 12px;
}
.sort-label {
  font-size: 0.8rem;
  color: var(--muted);
}
.sort-btns {
  display: flex;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.sort-btn {
  background: none;
  border: none;
  border-right: 1px solid var(--border-mid);
  padding: 4px 14px;
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
}
.sort-btn:last-child { border-right: none; }
.sort-btn.active { background: var(--accent); color: #fff; }
.sort-btn:not(.active):hover { background: var(--border); }

.results-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}
.results-header-row .btn {
  margin-top: 6px;
  flex-shrink: 0;
}

.results-idea-section {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.results-idea-label {
  font-size: 0.67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--accent);
  margin-bottom: 5px;
}

.results-app-desc {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.55;
}

.results-credits {
  font-size: 0.75rem;
  color: var(--muted-light);
  margin-top: 6px;
  letter-spacing: 0.01em;
}

/* ---------- Find more modal ---------- */
.more-search-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.more-search-modal.hidden { display: none !important; }

.more-search-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17,24,39,0.45);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.more-search-modal-panel {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.16);
  overflow: hidden;
}

.more-search-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.more-search-modal-body {
  padding: 24px;
}
.more-search-modal-body .custom-term-row { margin-top: 16px; }
.more-search-modal-body .btn { margin-top: 0; }

.more-search-app-desc {
  font-size: 0.82rem;
  color: var(--muted);
  background: var(--bg);
  border-left: 3px solid var(--border-mid);
  border-radius: 0 6px 6px 0;
  padding: 10px 14px;
  margin-bottom: 16px;
  max-height: 100px;
  overflow-y: auto;
  line-height: 1.55;
  white-space: pre-wrap;
}

/* ---------- Screenshots gallery tab ---------- */
.screenshots-gallery {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 4px 0;
}

.screenshots-row-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  cursor: pointer;
  width: fit-content;
}
.screenshots-row-header:hover .screenshots-row-name { color: var(--accent); }
.screenshots-row-header:hover .screenshots-row-arrow { opacity: 1; }

.screenshots-row-icon {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  flex-shrink: 0;
}

.screenshots-row-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
  transition: color 0.15s;
}

.screenshots-row-arrow {
  font-size: 0.8rem;
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.15s;
}

.screenshots-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-mid) transparent;
}
.screenshots-strip::-webkit-scrollbar { height: 4px; }
.screenshots-strip::-webkit-scrollbar-track { background: transparent; }
.screenshots-strip::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 2px; }

.screenshots-strip img {
  height: 220px;
  width: auto;
  flex-shrink: 0;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.15s ease;
  display: block;
}
.screenshots-strip img:hover { transform: scale(1.02); }

/* ---------- Dismiss button ---------- */
.dismiss-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted-light);
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, background 0.15s;
}
.result-card:hover .dismiss-btn { opacity: 1; }
.dismiss-btn:hover { color: #EF4444; background: #FEF2F2; }

/* ---------- Save button ---------- */
.save-btn {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--border-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  line-height: 0;
}
.save-btn:hover { color: var(--mid); background: var(--mid-soft); }
.save-btn.saved { color: var(--mid); }

.saved-tab-count, .removed-tab-count {
  display: inline-block;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 7px;
  margin-left: 5px;
  vertical-align: middle;
}
.saved-tab-count { background: var(--accent); color: #fff; }
.removed-tab-count { background: var(--low-soft); color: var(--muted); border: 1px solid var(--border-mid); }

/* ---------- Removed tab ---------- */
.removed-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 0;
}
.removed-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--panel);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s;
}
.removed-card:hover { border-color: var(--border-mid); }
.removed-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex-shrink: 0;
}
.removed-card-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.removed-card-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.removed-card-dev {
  font-size: 0.78rem;
  color: var(--muted);
}
.restore-btn {
  flex-shrink: 0;
  font-size: 0.8rem !important;
  padding: 6px 14px !important;
  margin-top: 0 !important;
}

/* ---------- Show-more button ---------- */
.show-more-btn {
  background: none;
  border: 1px solid var(--border-mid);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.79rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  padding: 6px 13px;
  transition: all 0.14s;
  align-self: flex-start;
  letter-spacing: -0.01em;
}
.show-more-btn:hover {
  border-color: var(--ink);
  color: var(--ink);
  background: var(--bg);
}

/* ---------- App detail modal ---------- */
.app-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.app-modal.hidden { display: none !important; }

.app-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17,24,39,0.45);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.app-modal-panel {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 80px rgba(0,0,0,0.16);
}

.app-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: all 0.12s;
}
.app-modal-close:hover { color: var(--ink); background: var(--border-mid); }

.app-modal-body {
  overflow-y: auto;
  padding: 28px 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.modal-header {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding-right: 28px;
}

.modal-icon {
  width: 66px;
  height: 66px;
  border-radius: 16px;
  flex-shrink: 0;
  background: var(--bg);
  object-fit: cover;
  border: 1px solid var(--border);
}

.modal-title-block { flex: 1; }
.modal-app-name { font-size: 1.1rem; font-weight: 700; letter-spacing: -0.025em; color: var(--ink); }
.modal-dev { font-size: 0.81rem; color: var(--muted); margin-top: 3px; }
.modal-meta { font-size: 0.77rem; color: var(--muted-light); margin-top: 3px; }

.modal-score-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.modal-score-label { font-size: 0.77rem; color: var(--muted); }

.modal-screenshots {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-mid) transparent;
  padding-bottom: 4px;
}
.modal-screenshots img {
  height: 190px;
  width: auto;
  border-radius: 12px;
  flex-shrink: 0;
  object-fit: cover;
  background: var(--bg);
}

.modal-section-title {
  font-size: 0.67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--muted);
  margin: 0 0 10px;
}

.modal-description {
  font-size: 0.88rem;
  line-height: 1.72;
  color: var(--ink);
  white-space: pre-line;
}

.modal-summary {
  font-size: 0.9rem;
  line-height: 1.65;
  color: var(--muted);
}

.modal-store-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  transition: opacity 0.14s;
}
.modal-store-link:hover { opacity: 0.75; }

.modal-screenshots-loading {
  font-size: 0.81rem;
  color: var(--muted-light);
}
