/* The Chat model picker panel (model-picker.js): glass panel, filter chips, and a grid of model
   cards with the company logo. The "Genexts glow": a teal/cyan light that follows the pointer
   over a card, and a slowly turning gradient ring around the chosen model. */
@property --gx-spin { syntax: '<angle>'; inherits: false; initial-value: 0deg; }

.mp-btn-logo { display: inline-grid; place-items: center; width: 18px; height: 18px; flex: 0 0 auto; }
.mp-btn-logo svg { width: 18px; height: 18px; }
.mp-btn-logo .mpx-mono { font-size: 10px; width: 18px; height: 18px; border-radius: 5px; }

.mpx { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 16px; }
.mpx[hidden] { display: none; }
.mpx-scrim { position: absolute; inset: 0; background: rgba(4, 6, 8, 0.45); opacity: 0; transition: opacity 0.22s ease;
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.mpx.in .mpx-scrim { opacity: 1; }

.mpx-box {
  position: relative; display: flex; flex-direction: column; width: min(1000px, 100%); height: min(760px, calc(100dvh - 32px));
  border-radius: 24px; overflow: hidden;
  background:
    radial-gradient(600px 300px at 0% 0%, rgba(46, 230, 182, 0.14), transparent 60%),
    radial-gradient(500px 300px at 100% 100%, rgba(139, 92, 246, 0.14), transparent 60%),
    color-mix(in srgb, var(--r-surface, #17181b) 62%, transparent);
  -webkit-backdrop-filter: blur(28px) saturate(1.5); backdrop-filter: blur(28px) saturate(1.5);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.10), 0 30px 80px rgba(0, 0, 0, 0.45);
  opacity: 0; transform: translateY(14px) scale(0.98); transition: opacity 0.22s ease, transform 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.mpx.in .mpx-box { opacity: 1; transform: none; }

.mpx-head { display: flex; align-items: center; gap: 12px; padding: 14px 14px 14px 18px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); flex-wrap: wrap; }
.mpx-search { flex: 1 1 200px; display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--r-text-2, #a9a9b2); }
.mpx-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--r-text, #ececef); font: inherit; font-size: 16px; }
.mpx-search input::-webkit-search-cancel-button { display: none; }
.mpx-chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.mpx-chips::-webkit-scrollbar { display: none; }
.mpx-chip { flex: 0 0 auto; padding: 7px 14px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, 0.08); cursor: pointer;
  background: rgba(255, 255, 255, 0.05); color: var(--r-text-2, #a9a9b2); font-family: inherit; font-size: 13.5px; font-weight: 600; line-height: 1;
  transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.15s; }
.mpx-chip:hover { color: var(--r-text, #ececef); background: rgba(255, 255, 255, 0.09); }
.mpx-chip:active { transform: scale(0.96); }
.mpx-chip.on { color: #04110d; background: linear-gradient(135deg, #2ee6b6, #22d3ee); border-color: transparent; }
.mpx-close { flex: 0 0 auto; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255, 255, 255, 0.06); color: var(--r-text-2, #a9a9b2); }
.mpx-close:hover { color: var(--r-text, #ececef); background: rgba(255, 255, 255, 0.12); }

.mpx-grid { flex: 1; overflow-y: auto; padding: 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px; align-content: start; overscroll-behavior: contain; }
.mpx-group { grid-column: 1 / -1; margin: 10px 2px -2px; font-size: 11.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--r-text-3, #6b6b74); }
.mpx-empty { grid-column: 1 / -1; padding: 48px 0; text-align: center; color: var(--r-text-2, #a9a9b2); }

.mpx-card {
  --mx: 50%; --my: 0%;
  position: relative; isolation: isolate; display: flex; flex-direction: column; gap: 6px; min-height: 150px; padding: 16px;
  border-radius: 18px; border: 1px solid rgba(255, 255, 255, 0.09); cursor: pointer; text-align: left; color: var(--r-text, #ececef); font: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.025));
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), border-color 0.2s, box-shadow 0.25s;
  animation: mpx-in 0.36s cubic-bezier(0.2, 0.8, 0.2, 1) both; animation-delay: var(--d, 0ms);
}
/* The light that follows the pointer. */
.mpx-card::before { content: ''; position: absolute; inset: 0; border-radius: inherit; z-index: -1; opacity: 0; transition: opacity 0.25s;
  background: radial-gradient(260px circle at var(--mx) var(--my), rgba(46, 230, 182, 0.16), rgba(34, 211, 238, 0.06) 40%, transparent 70%); }
.mpx-card:hover::before, .mpx-card:focus-visible::before { opacity: 1; }
.mpx-card:hover { transform: translateY(-3px); border-color: rgba(46, 230, 182, 0.35); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 12px 30px rgba(0, 0, 0, 0.25); }
.mpx-card:active { transform: translateY(-1px) scale(0.985); }
.mpx-card:focus-visible { outline: none; border-color: rgba(46, 230, 182, 0.6); }

/* The chosen model: a turning teal → cyan → violet ring. */
.mpx-card[aria-pressed="true"] { border-color: transparent; }
.mpx-card[aria-pressed="true"]::after { content: ''; position: absolute; inset: -1px; border-radius: inherit; padding: 1.5px; pointer-events: none;
  background: conic-gradient(from var(--gx-spin), #2ee6b6, #22d3ee, #8b5cf6, #2ee6b6);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
  animation: gx-spin 4s linear infinite; }

.mpx-card.featured { grid-column: span 2; min-height: 150px;
  background: radial-gradient(420px 200px at 0% 0%, rgba(46, 230, 182, 0.22), transparent 70%),
              radial-gradient(420px 220px at 100% 100%, rgba(139, 92, 246, 0.22), transparent 70%),
              linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
  border-color: rgba(46, 230, 182, 0.28); }
.mpx-card.featured .mpx-name { font-size: 20px; }

.mpx-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: auto; padding-bottom: 14px; }
.mpx-logo { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; flex: 0 0 auto; color: var(--r-text, #ececef);
  background: rgba(255, 255, 255, 0.07); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08); }
.mpx-logo svg { width: 24px; height: 24px; }
.mpx-mono { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; font-weight: 800; font-size: 14px; letter-spacing: -0.02em;
  color: #fff; background: linear-gradient(135deg, #475569, #1e293b); }
.mpx-tags { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.mpx-rec, .mpx-new, .mpx-backup { padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.mpx-rec { color: #2ee6b6; border: 1px solid rgba(46, 230, 182, 0.45); background: rgba(46, 230, 182, 0.08); }
.mpx-new { color: #7dd3fc; border: 1px solid rgba(125, 211, 252, 0.45); background: rgba(125, 211, 252, 0.08); }
.mpx-backup { color: #fbbf24; border: 1px solid rgba(251, 191, 36, 0.45); background: rgba(251, 191, 36, 0.08); }
.mpx-cost { display: inline-flex; gap: 3px; align-items: flex-end; height: 14px; }
.mpx-cost i { display: block; width: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.16); }
.mpx-cost i:nth-child(1) { height: 6px; } .mpx-cost i:nth-child(2) { height: 10px; } .mpx-cost i:nth-child(3) { height: 14px; }
.mpx-cost i.on { background: linear-gradient(180deg, #fbbf24, #f59e0b); }

.mpx-name { font-size: 16.5px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.25; }
.mpx-desc { font-size: 13px; line-height: 1.45; color: var(--r-text-2, #a9a9b2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mpx-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }
.mpx-co { font-size: 12px; color: var(--r-text-3, #6b6b74); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mpx-foot .mp-badge.puter { color: #c4b5fd; background: rgba(139, 92, 246, 0.1); border: 1px solid rgba(139, 92, 246, 0.3); }

@keyframes mpx-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes gx-spin { to { --gx-spin: 360deg; } }
html.mpx-open { overflow: hidden; }

/* Phones: a sheet from the bottom, two cards per row. */
@media (max-width: 640px) {
  .mpx { padding: 0; place-items: end stretch; }
  .mpx-box { width: 100%; height: min(86dvh, 760px); border-radius: 24px 24px 0 0; transform: translateY(40px); padding-bottom: env(safe-area-inset-bottom); }
  .mpx-head { padding: 12px; gap: 10px; }
  .mpx-search { order: 1; flex: 1 1 auto; }
  .mpx-close { order: 2; }
  .mpx-chips { order: 3; flex: 1 1 100%; }
  .mpx-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 12px; }
  .mpx-card { min-height: 128px; padding: 12px; border-radius: 16px; }
  .mpx-card.featured { grid-column: 1 / -1; }
  .mpx-logo, .mpx-mono { width: 34px; height: 34px; border-radius: 10px; }
  .mpx-logo svg { width: 20px; height: 20px; }
  .mpx-name { font-size: 15px; }
  .mpx-desc { font-size: 12px; }
  .mpx-co { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .mpx-card, .mpx-box, .mpx-scrim { animation: none; transition: none; }
  .mpx-card[aria-pressed="true"]::after { animation: none; }
}

/* Light theme */
html[data-theme="light"] .mpx-box { background:
    radial-gradient(600px 300px at 0% 0%, rgba(13, 148, 136, 0.12), transparent 60%),
    radial-gradient(500px 300px at 100% 100%, rgba(139, 92, 246, 0.10), transparent 60%),
    rgba(255, 255, 255, 0.72);
  border-color: rgba(15, 23, 42, 0.10); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 30px 80px rgba(15, 23, 42, 0.18); }
html[data-theme="light"] .mpx-scrim { background: rgba(15, 23, 42, 0.18); }
html[data-theme="light"] .mpx-head { border-color: rgba(15, 23, 42, 0.08); }
html[data-theme="light"] .mpx-chip { background: rgba(15, 23, 42, 0.04); border-color: rgba(15, 23, 42, 0.08); }
html[data-theme="light"] .mpx-close { background: rgba(15, 23, 42, 0.05); }
html[data-theme="light"] .mpx-card { background: linear-gradient(180deg, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0.55));
  border-color: rgba(15, 23, 42, 0.08); box-shadow: inset 0 1px 0 #fff, 0 1px 2px rgba(15, 23, 42, 0.04); }
html[data-theme="light"] .mpx-card:hover { border-color: rgba(13, 148, 136, 0.4); box-shadow: 0 12px 30px rgba(15, 23, 42, 0.10); }
html[data-theme="light"] .mpx-logo { background: rgba(15, 23, 42, 0.04); box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.06); }
html[data-theme="light"] .mpx-cost i { background: rgba(15, 23, 42, 0.14); }
html[data-theme="light"] .mpx-rec { color: #0d9488; }
html[data-theme="light"] .mpx-new { color: #0369a1; }
html[data-theme="light"] .mpx-backup { color: #b45309; }

/* Keep every line of a card at full height (overflow:hidden would let flexbox squash the description). */
.mpx-card > * { flex-shrink: 0; }
.mpx-search input, .mpx-search input:focus { outline: none !important; box-shadow: none !important; border: 0 !important; background: transparent !important; padding: 0 !important; }
.mpx-grid { grid-auto-rows: max-content; }
.mpx-card { height: auto; }

/* Genexts Pro's bar above the chat box */
.pro-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; width: 100%; max-width: 780px; margin: 0 auto 8px; font-size: 13px; }
.pro-bar.hidden { display: none; }
.pro-levels { display: inline-flex; padding: 2px; border-radius: 999px; background: rgba(127, 127, 127, .14); }
.pro-bar button { min-height: 32px; padding: 4px 12px; border: 0; border-radius: 999px; background: transparent; color: inherit; font: inherit; cursor: pointer; }
.pro-levels button[aria-checked="true"] { background: rgba(127, 127, 127, .32); font-weight: 600; }
.pro-private, .pro-saved { background: rgba(127, 127, 127, .14) !important; }
.pro-private[aria-pressed="true"] { background: rgba(32, 201, 151, .24) !important; font-weight: 600; }
.pro-list { position: fixed; z-index: 1000; left: 50%; bottom: 96px; transform: translateX(-50%); width: min(460px, calc(100vw - 32px)); max-height: 50vh; overflow: auto; padding: 16px; border-radius: 14px; background: var(--bg-panel, #15181d); color: var(--text-primary, #f2f4f7); border: 1px solid rgba(127, 127, 127, .3); box-shadow: 0 12px 40px rgba(0, 0, 0, .4); font-size: 14px; }
.pro-list h4 { margin: 0 0 4px; font-size: 15px; }
.pro-list p { margin: 0 0 10px; opacity: .75; font-size: 13px; }
.pro-list li { display: flex; gap: 8px; align-items: flex-start; justify-content: space-between; padding: 8px 0; border-top: 1px solid rgba(127, 127, 127, .2); list-style: none; word-break: break-word; }
.pro-list ul { margin: 0; padding: 0; }
.pro-list button { flex: none; min-height: 32px; padding: 4px 10px; border: 0; border-radius: 8px; background: rgba(127, 127, 127, .2); color: inherit; font: inherit; cursor: pointer; }
