/* Marketplace modal overlay */

.mkt-overlay {
  position: fixed; inset: 0; z-index: 350;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
}

.mkt-modal {
  width: min(1240px, calc(100vw - 80px));
  height: min(860px, calc(100vh - 80px));
  border-radius: 24px;
  background: var(--bg-panel);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-pop);
  padding: 32px 40px;
  display: flex; flex-direction: column;
  overflow: hidden;
}

/* ---- header ---------------------------------------------------------------- */

.mkt-header { display: flex; align-items: center; gap: 16px; flex: none; }
.mkt-title { font-size: 24px; font-weight: 700; flex: 1; min-width: 0; }

.mkt-tabs { display: flex; align-items: center; gap: 8px; }
.mkt-tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 18px; border-radius: var(--radius-pill);
  font-size: 15px; font-weight: 600;
  background: transparent; border: 1px solid var(--hairline-strong);
  color: var(--text-secondary);
}
.mkt-tab:hover { color: var(--text-primary); background: var(--bg-elev1); }
.mkt-tab.selected {
  background: var(--white-btn); color: #000; border-color: transparent;
}
.mkt-tab svg { flex: none; }

.mkt-close { flex: none; }

/* ---- detail header --------------------------------------------------------- */

.mkt-detail-header { position: relative; justify-content: space-between; }
.mkt-detail-title {
  position: absolute; left: 50%; transform: translateX(-50%);
  font-size: 17px; font-weight: 600;
  max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---- installed strip ------------------------------------------------------- */

.mkt-installed {
  display: flex; align-items: center; gap: 12px;
  margin: 18px 0; cursor: pointer; flex: none;
  border-radius: 10px; padding: 4px 6px; margin-left: -6px;
  align-self: flex-start;
}
.mkt-installed:hover { background: var(--bg-elev1); }
.mkt-installed-tiles { display: inline-flex; align-items: center; }
.mkt-installed-tiles .logo-tile {
  border-radius: 6px; margin-right: -6px;
  border: 1px solid rgba(0,0,0,.25);
}
.mkt-installed-tiles .logo-tile:last-child { margin-right: 0; }
.mkt-installed-tiles .logo-tile svg { width: 17px; height: 17px; }
.mkt-installed-text { font-size: 15px; margin-left: 6px; }
.mkt-installed-chev { color: var(--text-tertiary); display: inline-flex; }

/* ---- search ---------------------------------------------------------------- */

.mkt-search {
  position: relative; flex: none;
  height: 48px; border-radius: 14px; background: var(--bg-input);
  display: flex; align-items: center;
}
.mkt-search-icon {
  position: absolute; left: 16px; color: var(--text-tertiary);
  display: inline-flex; pointer-events: none;
}
.mkt-search input {
  width: 100%; height: 100%; background: transparent;
  border-radius: 14px; padding: 0 16px 0 46px; font-size: 15px;
}

/* ---- category chips -------------------------------------------------------- */

.mkt-chips {
  display: flex; align-items: center; gap: 8px;
  margin: 16px 0 8px; flex: none; flex-wrap: wrap;
}
.mkt-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 16px; border-radius: var(--radius-pill);
  font-size: 14px; font-weight: 500;
  background: var(--bg-elev2); color: var(--text-primary);
  white-space: nowrap;
}
.mkt-chip:hover { background: var(--bg-elev3); }
.mkt-chip.selected { background: var(--white-btn); color: #000; font-weight: 600; }
.mkt-chip-chev { display: inline-flex; color: var(--text-secondary); }
.mkt-chip.selected .mkt-chip-chev { color: #000; }

/* ---- scroll body ----------------------------------------------------------- */

.mkt-scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; }

/* ---- sections + plugin grid ------------------------------------------------ */

.mkt-section-title { font-size: 20px; font-weight: 700; margin: 18px 0 6px; }
.mkt-section-head { display: flex; align-items: baseline; justify-content: space-between; }
.mkt-viewall { font-size: 15px; color: var(--text-secondary); }
.mkt-viewall:hover { color: var(--text-primary); }

.mkt-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 4px 24px;
}

.mkt-row {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 8px; border-radius: 12px;
  cursor: pointer; min-width: 0;
}
.mkt-row:hover { background: var(--bg-elev1); }

.logo-tile {
  display: inline-flex; align-items: center; justify-content: center;
  background: #fff; border-radius: 12px; flex: none;
}
.mkt-row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mkt-row-name { font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mkt-row-desc {
  font-size: 14px; color: var(--text-secondary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mkt-row-action { flex: none; }

/* Normalize brand SVG sizes inside grid tiles (some logos have 22px intrinsic width). */
.mkt-row .logo-tile svg { width: 30px; height: 30px; }

.mkt-add-pill {
  background: var(--bg-elev3); border-radius: var(--radius-pill);
  padding: 7px 18px; font-size: 15px; font-weight: 600;
}
.mkt-add-pill:hover { background: #3a3a3e; }

.mkt-added {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 15px; color: var(--text-secondary); padding: 7px 4px;
}
.mkt-added:hover { color: var(--text-primary); }
.mkt-added-check { color: var(--green); display: inline-flex; }

/* ---- bots grid ------------------------------------------------------------- */

.mkt-bots-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 20px; margin-top: 22px;
}
.mkt-bot-card {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 28px 16px 22px; border-radius: 16px;
  background: var(--bg-elev1); border: 1px solid var(--hairline);
}
.mkt-bot-card:hover { background: var(--bg-elev2); }
.mkt-bot-name { font-size: 16px; font-weight: 600; }

/* ---- detail view ----------------------------------------------------------- */

.mkt-hero { display: flex; align-items: center; gap: 20px; margin: 24px 0; min-width: 0; }
.mkt-hero .logo-tile { border-radius: 16px; }
.mkt-hero .logo-tile svg { width: 44px; height: 44px; }
.mkt-hero-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.mkt-hero-name { font-size: 22px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mkt-source {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 15px; color: var(--text-secondary); align-self: flex-start;
  padding: 0;
}
.mkt-source:hover { text-decoration: underline; color: var(--text-primary); }
.mkt-source-icon { display: inline-flex; color: var(--text-tertiary); }

.mkt-hero-actions { display: flex; align-items: center; gap: 10px; flex: none; }
.mkt-pill-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg-elev2); border-radius: var(--radius-pill);
  padding: 10px 18px; font-size: 15px; font-weight: 600;
}
.mkt-pill-btn:hover { background: var(--bg-elev3); }

.mkt-detail-desc { font-size: 16px; color: var(--text-primary); line-height: 1.45; }

.mkt-label { font-size: 15px; color: var(--text-secondary); margin: 22px 0 8px; }

.mkt-card {
  background: var(--bg-elev1); border-radius: 14px;
  border: 1px solid var(--hairline); overflow: hidden;
}
.mkt-card-row {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 16px; font-size: 16px; width: 100%; text-align: left;
}
.mkt-card-btn { cursor: pointer; }
.mkt-card-btn:hover { background: var(--bg-elev2); }
.mkt-card-sep { height: 1px; background: var(--hairline); margin: 0 16px; }

.mkt-acct-name { font-size: 16px; }
.mkt-acct-pencil { display: inline-flex; color: var(--text-tertiary); }
.mkt-connected { margin-left: auto; font-size: 15px; color: var(--green); }
.mkt-plus-ic { display: inline-flex; color: var(--text-secondary); }

.mkt-chev {
  margin-left: auto; display: inline-flex; color: var(--text-tertiary);
  transition: transform .2s ease;
}
.mkt-chev.open { transform: rotate(180deg); }

.mkt-tools { padding: 0 0 6px; }
.mkt-tool-row {
  display: flex; align-items: center;
  padding: 11px 16px 11px 32px;
  border-top: 1px solid var(--hairline);
  font-size: 15px;
}
.mkt-tool-name { font-family: var(--font-mono); font-size: 13.5px; color: var(--text-primary); }
.mkt-conn-name { font-family: var(--font-ui); font-size: 15px; }
.mkt-tool-on {
  margin-left: auto; width: 34px; height: 20px; border-radius: 999px;
  background: var(--green); position: relative; flex: none;
}
.mkt-tool-dot {
  position: absolute; top: 2px; right: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff;
}

/* "More" category menu must float above the marketplace overlay (z 350). */
.popover.mkt-more-menu { z-index: 400; }

/* ---- empty search state ---------------------------------------------------- */

.mkt-empty {
  padding: 48px 0; text-align: center;
  color: var(--text-tertiary); font-size: 15px;
}

/* ---- connect pill (detail hero) -------------------------------------------- */

.mkt-connect-pill {
  background: var(--white-btn); color: #000;
  border-radius: var(--radius-pill);
  padding: 10px 26px; font-size: 15px; font-weight: 600;
}
.mkt-connect-pill:hover { background: #e8e8ec; }

/* ---- per-tool toggles ------------------------------------------------------- */

.mkt-tools-count { color: var(--text-secondary); font-size: 15px; }

.mkt-tool-toggle {
  margin-left: auto; width: 34px; height: 20px; border-radius: 999px;
  background: var(--bg-elev3); position: relative; flex: none;
  cursor: pointer; transition: background .15s ease;
}
.mkt-tool-toggle.on { background: var(--green); }
.mkt-tool-knob {
  position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; transition: transform .15s ease;
}
.mkt-tool-toggle.on .mkt-tool-knob { transform: translateX(14px); }

/* ---- GitHub repositories card ---------------------------------------------- */

.mkt-repo-row { gap: 10px; }
.mkt-repo-ic { display: inline-flex; color: var(--text-tertiary); flex: none; }
.mkt-repo-name {
  font-family: var(--font-mono); font-size: 13.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mkt-repo-row .mkt-connected { display: inline-flex; }

/* ---- connect modal (Claude-style) ------------------------------------------ */

.mkt-connect-overlay {
  position: fixed; inset: 0; z-index: 380;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
}
.mkt-connect {
  width: 420px; max-width: calc(100vw - 48px);
  background: var(--bg-menu); border: 1px solid var(--hairline);
  border-radius: 24px; box-shadow: var(--shadow-pop);
  padding: 36px 32px 28px;
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
}
.mkt-connect-logo { margin-bottom: 20px; }
.mkt-connect-logo .logo-tile { border-radius: 16px; }
.mkt-connect-logo .logo-tile svg { width: 60%; height: 60%; }
.mkt-connect-title { font-size: 20px; font-weight: 700; margin-bottom: 10px; }
.mkt-connect-sub {
  font-size: 15px; color: var(--text-secondary); line-height: 1.45;
  margin-bottom: 26px; max-width: 320px;
}
.mkt-connect-actions {
  display: flex; flex-direction: column; gap: 10px;
  width: 100%; margin-top: auto;
}
.mkt-connect-continue {
  width: 100%; padding: 12px 0; border-radius: var(--radius-pill);
  background: var(--white-btn); color: #000;
  font-size: 16px; font-weight: 600;
}
.mkt-connect-continue:hover { background: #e8e8ec; }
.mkt-connect-continue.disabled { opacity: .4; cursor: default; }
.mkt-connect-continue.disabled:hover { background: var(--white-btn); }
.mkt-connect-cancel {
  width: 100%; padding: 11px 0; border-radius: var(--radius-pill);
  background: transparent; color: var(--text-secondary);
  font-size: 15px; font-weight: 600;
}
.mkt-connect-cancel:hover { background: var(--bg-elev1); color: var(--text-primary); }

.mkt-connect-progress {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 0 10px; font-size: 16px; color: var(--text-secondary);
}
.mkt-spinner {
  width: 18px; height: 18px; border-radius: 50%; flex: none;
  border: 2.5px solid var(--hairline-strong);
  border-top-color: var(--white-btn);
  animation: mkt-spin .8s linear infinite;
}
@keyframes mkt-spin { to { transform: rotate(360deg); } }

/* ---- GitHub repo picker step ----------------------------------------------- */

.mkt-repo-modes {
  width: 100%; display: flex; flex-direction: column;
  border: 1px solid var(--hairline); border-radius: 14px;
  overflow: hidden; margin-bottom: 12px;
}
.mkt-repo-mode {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; font-size: 15px; text-align: left;
  background: var(--bg-elev1);
}
.mkt-repo-mode + .mkt-repo-mode { border-top: 1px solid var(--hairline); }
.mkt-repo-mode:hover { background: var(--bg-elev2); }
.mkt-radio {
  width: 18px; height: 18px; border-radius: 50%; flex: none;
  border: 1.5px solid var(--hairline-strong); position: relative;
}
.mkt-radio.on { border-color: var(--white-btn); }
.mkt-radio.on::after {
  content: ''; position: absolute; inset: 3px;
  border-radius: 50%; background: var(--white-btn);
}
.mkt-repo-list {
  width: 100%; display: flex; flex-direction: column;
  border: 1px solid var(--hairline); border-radius: 14px;
  overflow: hidden; margin-bottom: 22px;
  max-height: 200px; overflow-y: auto;
  transition: opacity .15s ease;
}
.mkt-repo-list.dim { opacity: .4; pointer-events: none; }
.mkt-repo-check {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; text-align: left;
}
.mkt-repo-check + .mkt-repo-check { border-top: 1px solid var(--hairline); }
.mkt-repo-check:hover { background: var(--bg-elev1); }
.mkt-checkbox {
  width: 18px; height: 18px; border-radius: 5px; flex: none;
  border: 1.5px solid var(--hairline-strong);
  display: inline-flex; align-items: center; justify-content: center;
  color: #000;
}
.mkt-checkbox.on { background: var(--white-btn); border-color: var(--white-btn); }

/* ---- narrow screens -------------------------------------------------------- */

@media (max-width: 900px) {
  .mkt-modal {
    width: calc(100vw - 24px); height: calc(100vh - 24px);
    padding: 20px 18px; border-radius: 20px;
  }
  .mkt-grid { grid-template-columns: 1fr; }
  .mkt-bots-grid { grid-template-columns: repeat(2, 1fr); }
  .mkt-title { font-size: 20px; }
  .mkt-hero { flex-wrap: wrap; }
}
@media (max-width: 640px) {
  .mkt-modal {
    width: 100vw; height: 100vh; height: 100dvh;
    border-radius: 0; border: none; padding: 18px 16px;
  }
  .mkt-connect-overlay { align-items: stretch; justify-content: stretch; }
  .mkt-connect {
    width: 100vw; max-width: none; height: 100vh; height: 100dvh;
    border-radius: 0; border: none; justify-content: center;
    padding: 32px 24px;
  }
  .mkt-connect-actions { margin-top: 28px; }
}
@media (max-width: 480px) {
  .mkt-bots-grid { grid-template-columns: 1fr; }
  .mkt-tab span { display: none; }
  .mkt-tab { padding: 8px 12px; }
}
