/* ═══════════════════════════════════════════════════════════
 * Model picker v2 — search, capability chips, keyboard nav
 * Layout: fixed header (title + search + chips), scrollable
 * list, fixed footer. Wide modal, responsive sheet on mobile.
 *
 * 🔴 Selector MUST stay as `.model-picker.model-picker-v2` (chained,
 * specificity 0,2,0). The legacy `.model-picker { max-width: 400px }`
 * rule lives further down in this same file and wins against a bare
 * `.model-picker-v2` (equal specificity, later source). Chained
 * selector outranks it and keeps the wide layout intact. Three user
 * complaints in a row were caused by forgetting this — do NOT
 * "simplify" to the single-class form.
 * ═══════════════════════════════════════════════════════════ */
.model-picker.model-picker-v2 {
    background: linear-gradient(180deg, var(--panel) 0%, var(--bg) 100%);
    border: 1px solid var(--green-dim);
    border-radius: 16px;
    padding: 0;
    /* Maximally wide: almost full viewport on desktop, capped at 1680px
     * so 4K monitors don't render a cinemascope dialog. Leaves a 24px
     * margin from the screen edge. */
    max-width: min(960px, calc(100vw - 48px));
    width: min(960px, calc(100vw - 48px));
    /* Taller too — 94vh uses the whole screen on desktop, leaving just
     * a small margin for the overlay backdrop. */
    max-height: 94vh;
    min-height: min(560px, 80vh);
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 72px rgba(0, 0, 0, 0.35), 0 0 48px rgba(var(--green-rgb), 0.1);
    overflow: hidden;
}

/* ── Header ── */
.mp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px 12px;
    border-bottom: 1px solid rgba(var(--green-rgb), 0.12);
    flex-shrink: 0;
}

.mp-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--green);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    display: flex;
    align-items: center;
    gap: 6px;
}

.mp-close {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--panel-2);
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.18s ease;
}

.mp-close:hover {
    background: rgba(var(--red-rgb), 0.18);
    color: var(--red);
    border-color: rgba(var(--red-rgb), 0.45);
    transform: rotate(90deg);
}

/* Refresh button — sits between title and close. Muted by default to avoid
   competing with the primary Close action, highlights on hover. */
.mp-refresh {
    margin-left: auto;
    margin-right: 8px;
    height: 30px;
    padding: 0 12px;
    border-radius: 6px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    cursor: pointer;
    transition: all 0.18s ease;
    white-space: nowrap;
}

.mp-refresh:hover:not(:disabled) {
    background: rgba(var(--green-rgb), 0.14);
    color: var(--green);
    border-color: rgba(var(--green-rgb), 0.45);
}

.mp-refresh:disabled {
    opacity: 0.6;
    cursor: wait;
}

/* ── Current-model banner (above search) ──
 * Shown in every picker mode (set, regenerate, ...) so the user always sees
 * which model they're switching FROM, with quick access to copy-ID / info
 * actions. Keeps the interface unified — no mode-specific UI forks. */
.mp-current {
    padding: 10px 18px;
    border-bottom: 1px solid rgba(var(--green-rgb), 0.12);
    background: rgba(var(--green-rgb), 0.04);
}

.mp-current-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 6px;
}

.mp-current-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mp-current-icon {
    font-size: 22px;
    line-height: 1;
    flex-shrink: 0;
}

.mp-current-info {
    flex: 1;
    min-width: 0;
}

.mp-current-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
}

.mp-current-badge {
    font-size: 11px;
    opacity: 0.85;
}

.mp-current-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
    font-size: 11px;
    color: var(--muted);
    overflow: hidden;
}

.mp-current-group {
    white-space: nowrap;
}

.mp-current-id {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
    font-size: 10px;
    padding: 1px 6px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 4px;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 260px;
}

.mp-current-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.mp-current-btn {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.mp-current-btn:hover {
    color: var(--green);
    border-color: rgba(var(--green-rgb), 0.45);
    background: rgba(var(--green-rgb), 0.1);
}

/* ── Search ── */
.mp-search-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    background: var(--panel-2);
    flex-shrink: 0;
    border-bottom: 1px solid rgba(var(--green-rgb), 0.08);
}

.mp-search-icon {
    font-size: 14px;
    opacity: 0.65;
    flex-shrink: 0;
}

.mp-search {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    padding: 6px 0;
    min-width: 0;
}

.mp-search::placeholder {
    color: var(--muted);
    opacity: 0.5;
}

.mp-search-clear {
    background: rgba(var(--green-rgb), 0.08);
    border: 1px solid var(--line);
    color: var(--muted);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mp-search-clear:hover {
    background: rgba(var(--red-rgb), 0.18);
    color: var(--red);
}

/* ── Capability chips — wrap to multiple rows so all are visible ── */
.mp-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 18px 12px;
    background: rgba(var(--green-rgb), 0.04);
    border-bottom: 1px solid rgba(var(--green-rgb), 0.08);
    flex-shrink: 0;
}

/* Family filter — horizontal scroll bar above capability chips */
.mp-families {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    padding: 8px 18px 8px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--line) transparent;
    flex-shrink: 0;
    -webkit-overflow-scrolling: touch;
}

.mp-families::-webkit-scrollbar { height: 4px; }
.mp-families::-webkit-scrollbar-thumb { background: var(--line); border-radius: 2px; }

.mp-family {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    color: var(--muted);
    font-family: inherit;
    font-size: 11px;
    border-radius: 999px;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.15s ease;
}

.mp-family:hover {
    border-color: var(--green-dim);
    color: var(--text);
    background: rgba(var(--green-rgb), 0.08);
}

.mp-family-active {
    background: rgba(var(--green-rgb), 0.18);
    border-color: var(--green);
    color: var(--green);
    font-weight: 600;
}

.mp-family-locked {
    opacity: 0.5;
}

.mp-family-icon {
    font-size: 13px;
}

.mp-family-count {
    font-size: 10px;
    background: rgba(var(--green-rgb), 0.1);
    padding: 1px 5px;
    border-radius: 8px;
    font-weight: normal;
}

.mp-family-active .mp-family-count {
    background: rgba(var(--green-rgb), 0.25);
}

.mp-chip {
    background: var(--panel-2);
    border: 1px solid var(--line);
    color: var(--muted);
    font-family: inherit;
    font-size: 11px;
    padding: 6px 12px;
    border-radius: 999px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
    line-height: 1.2;
}

.mp-chip:hover {
    background: rgba(var(--green-rgb), 0.08);
    color: var(--green-dim);
    border-color: var(--green-dim);
    transform: translateY(-1px);
}

.mp-chip-active {
    background: linear-gradient(135deg, rgba(var(--green-rgb), 0.22), rgba(var(--green-rgb), 0.1));
    border-color: var(--green);
    color: var(--green);
    font-weight: 700;
    box-shadow: 0 0 10px rgba(var(--green-rgb), 0.15);
}

/* ── Quick picks (task-based recommendations) ──
 * Horizontal carousel — a single row of compact cards with scroll-x.
 * Keeps the header area compact so the model list below has maximum
 * vertical space to scroll. Previous grid layout wrapped into 2-3
 * rows on narrow screens and ate half the modal height. */
.mp-quickpicks {
    padding: 8px 0 16px;  /* extra bottom padding so hover :translateY doesn't clip */
    background: rgba(var(--green-rgb), 0.04);
    border-bottom: 1px solid rgba(var(--green-rgb), 0.08);
    flex-shrink: 0;
}

.mp-quickpicks-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--amber);
    font-weight: 700;
    margin: 0 14px 6px;
    opacity: 0.8;
}

.mp-quickpicks-grid {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    padding: 4px 14px 4px;  /* top padding for hover lift */
    overflow-x: auto;
    overflow-y: visible;    /* allow hover translateY + shadow to escape */
    scrollbar-width: thin;
    scrollbar-color: rgba(var(--green-rgb), 0.3) transparent;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
}

.mp-quickpicks-grid::-webkit-scrollbar {
    height: 5px;
}

.mp-quickpicks-grid::-webkit-scrollbar-thumb {
    background: rgba(var(--green-rgb), 0.3);
    border-radius: 2px;
}

/* Compact horizontal layout: icon on the left, title+model stacked on
 * the right. Saves one row of vertical space vs the old column layout
 * and keeps the card ~46px tall so it comfortably fits inside the
 * quick-picks strip without clipping. The freshness badge (only on the
 * Free pick) absolute-positions top-right so it doesn't push the card
 * taller when present. */
.mp-quickpick {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 10px;
    row-gap: 1px;
    align-items: center;
    padding: 8px 12px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    transition: all 0.15s ease;
    overflow: hidden;
    flex: 0 0 auto;
    width: 190px;
    min-height: 46px;
    position: relative;
    scroll-snap-align: start;
}

.mp-quickpick:hover {
    background: rgba(var(--green-rgb), 0.08);
    border-color: var(--green-dim);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(var(--green-rgb), 0.1);
}

.mp-quickpick.disabled {
    opacity: 0.45;
    cursor: pointer;
    border-color: rgba(var(--amber-rgb), 0.25);
    background: rgba(var(--amber-rgb), 0.04);
}

.mp-quickpick.disabled:hover {
    background: rgba(var(--amber-rgb), 0.08);
    border-color: rgba(var(--amber-rgb), 0.4);
    box-shadow: 0 4px 12px rgba(var(--amber-rgb), 0.1);
}

.mp-quickpick-icon {
    grid-column: 1;
    grid-row: 1 / span 2;
    align-self: center;
    font-size: 20px;
    line-height: 1;
}

.mp-quickpick-title {
    grid-column: 2;
    grid-row: 1;
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.mp-quickpick-model {
    grid-column: 2;
    grid-row: 2;
    font-size: 10px;
    color: var(--muted);
    font-family: "Share Tech Mono", monospace;
    opacity: 0.7;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Freshness chip floats in the top-right corner so the card height
 * stays constant whether the Free badge is present or not. */
.mp-quickpick-freshness {
    position: absolute;
    top: 4px;
    right: 6px;
    padding: 1px 6px;
    background: rgba(var(--green-rgb), 0.12);
    border: 1px solid rgba(var(--green-rgb), 0.3);
    border-radius: 8px;
    font-size: 8px;
    color: var(--green);
    font-family: "Share Tech Mono", monospace;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
    line-height: 1.2;
    pointer-events: none;
}

/* ── List ── */
.mp-list {
    flex: 1;
    overflow-y: auto;
    padding: 14px 18px 18px;
    scrollbar-width: thin;
    scrollbar-color: rgba(var(--green-rgb), 0.3) transparent;
    overscroll-behavior: contain;
}

.mp-list::-webkit-scrollbar { width: 6px; }
.mp-list::-webkit-scrollbar-thumb {
    background: rgba(var(--green-rgb), 0.3);
    border-radius: 3px;
}

.mp-group-name {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--amber);
    padding: 12px 10px 6px;
    font-weight: 700;
    opacity: 0.8;
    position: sticky;
    top: 0;
    background: linear-gradient(180deg, var(--panel) 60%, var(--bg) 100%);
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: background 0.12s;
}

.mp-group-name[data-group]:hover {
    background: var(--panel-2);
}

.mp-group-toggle {
    font-size: 10px;
    color: var(--muted);
    transition: transform 0.15s;
    width: 12px;
}

.mp-group-label {
    flex: 1;
}

.mp-group-count {
    font-size: 10px;
    color: var(--muted);
    background: var(--panel-2);
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: normal;
    letter-spacing: 0;
    text-transform: none;
}

/* ── Row ── */
.mp-row {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 16px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, transform 0.12s;
    border: 1px solid transparent;
    margin: 5px 0;
    position: relative;
}

.mp-row:hover {
    background: rgba(var(--green-rgb), 0.06);
    border-color: rgba(var(--green-rgb), 0.25);
}

.mp-row-focused {
    background: rgba(var(--green-rgb), 0.1);
    border-color: var(--green-dim);
}

.mp-row-active {
    background: linear-gradient(180deg, rgba(var(--green-rgb), 0.12), rgba(var(--green-rgb), 0.04));
    border-color: var(--green);
    box-shadow: 0 0 16px rgba(var(--green-rgb), 0.18) inset;
}

.mp-row-locked {
    opacity: 0.6;
}

.mp-row-locked:hover {
    opacity: 0.85;
    background: rgba(var(--amber-rgb), 0.05);
    border-color: rgba(var(--amber-rgb), 0.25);
}

/* Row children */
.mp-row-icon {
    font-size: 22px;
    line-height: 1;
    flex-shrink: 0;
    width: 30px;
    text-align: center;
    padding-top: 2px;
}

.mp-row-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Top row: label + tags + capability pills */
.mp-row-top {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    min-width: 0;
}

.mp-row-label {
    font-size: 15px;
    color: var(--text);
    font-weight: 600;
    line-height: 1.3;
}

/* Bottom row: model id on the left, meta pills on the right */
.mp-row-bottom {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.mp-row-id {
    font-family: "Share Tech Mono", "SF Mono", Consolas, monospace;
    font-size: 11px;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
    opacity: 0.75;
}

.mp-meta {
    display: inline-flex;
    gap: 4px;
    flex-shrink: 0;
}

.mp-meta-pill {
    font-size: 10px;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(var(--green-rgb), 0.06);
    border: 1px solid var(--line);
    color: var(--muted);
    font-family: "Share Tech Mono", monospace;
    letter-spacing: 0.04em;
    line-height: 1.4;
    white-space: nowrap;
}

.mp-meta-pill-price {
    background: rgba(var(--amber-rgb), 0.08);
    border-color: rgba(var(--amber-rgb), 0.25);
    color: var(--amber);
}

/* Compact capability pills (🖼 🧠 🎨 💚) */
.mp-pills {
    display: inline-flex;
    gap: 3px;
    margin-left: 2px;
}

.mp-pill {
    font-size: 10px;
    line-height: 1;
    padding: 3px 7px;
    border-radius: 6px;
    background: rgba(var(--green-rgb), 0.05);
    color: var(--text);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.mp-pill-free {
    background: rgba(var(--green-rgb), 0.14);
    color: var(--green);
    border: 1px solid rgba(var(--green-rgb), 0.3);
}

.mp-pill-multimodal {
    background: rgba(98, 180, 255, 0.14);
    color: #62b4ff;
    border: 1px solid rgba(98, 180, 255, 0.35);
}

.mp-pill-reasoning {
    background: rgba(180, 120, 255, 0.14);
    color: #b478ff;
    border: 1px solid rgba(180, 120, 255, 0.35);
}

.mp-pill-imagegen {
    background: rgba(var(--amber-rgb), 0.14);
    color: var(--amber);
    border: 1px solid rgba(var(--amber-rgb), 0.35);
}

/* Tags — "✓ активна" / "🔒 Plus+" */
.mp-tag {
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 3px 7px;
    border-radius: 999px;
    white-space: nowrap;
    line-height: 1.2;
}

.mp-tag-active {
    background: var(--green);
    color: var(--bg);
    box-shadow: 0 0 10px rgba(var(--green-rgb), 0.4);
}

.mp-tag-locked {
    background: rgba(var(--amber-rgb), 0.18);
    color: var(--amber);
    border: 1px solid rgba(var(--amber-rgb), 0.4);
}

/* Copy id button */
/* Search highlight — matching query in model labels */
.mp-row-label mark,
.mp-row-id mark {
    background: rgba(var(--amber-rgb), 0.35);
    color: var(--text);
    padding: 0;
    border-radius: 2px;
    font-weight: 600;
}

/* ═══ Model Details Modal ═══ */
/* Must render ABOVE `.model-picker-overlay` (z 4500 in 07-improve-prompt.css)
 * because the details modal is opened from the picker's ℹ️ button — otherwise
 * the picker sits on top and eats all clicks, and the modal looks "gone"
 * even though it's mounted. z 4600 stays below toasts (10000). */
.model-details-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 4600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: overlayFadeIn 0.15s ease-out;
}

.model-details-modal {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 0;
    position: relative;
    animation: pickerSlideIn 0.2s ease-out;
}

.model-details-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--panel-2);
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
    z-index: 1;
}
.model-details-close:hover {
    background: rgba(var(--red-rgb), 0.18);
    color: var(--red);
    transform: rotate(90deg);
    transition: all 0.18s;
}

.model-details-hero {
    display: flex;
    gap: 16px;
    padding: 20px 48px 16px 20px;
    border-bottom: 1px solid var(--line);
    background: rgba(var(--green-rgb), 0.04);
    border-radius: 16px 16px 0 0;
}

.model-details-icon {
    font-size: 42px;
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--panel);
    border-radius: 12px;
    border: 1px solid var(--line);
}

.model-details-head {
    flex: 1;
    min-width: 0;
}

.model-details-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 4px;
}

.model-details-provider {
    font-size: 12px;
    color: var(--green-dim);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 8px;
}

.model-details-id {
    display: flex;
    gap: 6px;
    align-items: center;
}

.model-details-id code {
    font-family: "Share Tech Mono", monospace;
    font-size: 11px;
    color: var(--muted);
    background: var(--panel-2);
    padding: 3px 8px;
    border-radius: 4px;
    word-break: break-all;
    flex: 1;
}

.model-details-copy {
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 6px;
    width: 26px;
    height: 26px;
    padding: 0;
    cursor: pointer;
    font-size: 12px;
    color: var(--muted);
    flex-shrink: 0;
}
.model-details-copy:hover {
    border-color: var(--green-dim);
    color: var(--green);
}

.model-details-section {
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
}
.model-details-section:last-of-type {
    border-bottom: none;
}

.model-details-section-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
    margin-bottom: 10px;
    font-weight: 700;
}

.model-details-text {
    font-size: 13px;
    line-height: 1.55;
    color: var(--text);
}

.model-details-stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--line);
}

.model-details-stat {
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
}

.model-details-stat-label {
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 4px;
}

.model-details-stat-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.model-details-caps {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.model-details-caps li {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.mdc-icon {
    font-size: 18px;
    flex-shrink: 0;
    margin-top: 2px;
}

.model-details-caps li strong {
    display: block;
    font-size: 13px;
    color: var(--text);
    margin-bottom: 2px;
}

.mdc-desc {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.4;
    display: block;
}

.model-details-tags {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.model-details-tags li {
    font-size: 11px;
    padding: 4px 10px;
    background: rgba(var(--green-rgb), 0.08);
    border: 1px solid rgba(var(--green-rgb), 0.2);
    border-radius: 999px;
    color: var(--green);
}

.model-details-actions {
    display: flex;
    gap: 10px;
    padding: 16px 20px;
    background: var(--panel-2);
    border-radius: 0 0 16px 16px;
}

.model-details-btn {
    flex: 1;
    padding: 10px 16px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.model-details-btn:hover {
    border-color: var(--green-dim);
    background: rgba(var(--green-rgb), 0.08);
}

.model-details-btn-primary {
    background: var(--green);
    color: var(--bg);
    border-color: var(--green);
}
.model-details-btn-primary:hover {
    background: var(--green);
    opacity: 0.9;
}

.model-details-btn-admin {
    background: rgba(var(--amber-rgb), 0.1);
    border-color: rgba(var(--amber-rgb), 0.4);
    color: var(--amber);
}
.model-details-btn-admin:hover {
    background: rgba(var(--amber-rgb), 0.18);
    border-color: var(--amber);
}

.mp-row-copy,
.mp-row-fav,
.mp-row-info {
    background: var(--panel-2);
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: 14px;
    padding: 6px 9px;
    border-radius: 8px;
    cursor: pointer;
    flex-shrink: 0;
    opacity: 0.5;
    transition: all 0.15s;
    align-self: center;
}

.mp-row-fav.active {
    opacity: 1;
    color: var(--amber);
    background: rgba(var(--amber-rgb), 0.12);
    border-color: rgba(var(--amber-rgb), 0.3);
}

.mp-row:hover .mp-row-fav,
.mp-row:hover .mp-row-info,
.mp-row:hover .mp-row-copy {
    opacity: 1;
}

.mp-row-info:hover {
    opacity: 1 !important;
    background: rgba(var(--green-rgb), 0.15);
    border-color: var(--green-dim);
    color: var(--green);
    transform: scale(1.05);
}

.mp-row-fav:hover {
    opacity: 1 !important;
    color: var(--amber);
    transform: scale(1.2);
}

.mp-row:hover .mp-row-copy {
    opacity: 0.7;
}

.mp-row-copy:hover {
    opacity: 1 !important;
    background: rgba(var(--green-rgb), 0.15);
    border-color: var(--green-dim);
    color: var(--green);
    transform: scale(1.05);
}

/* ── Footer ── */
.model-picker-v2 .mp-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 18px;
    border-top: 1px solid rgba(var(--green-rgb), 0.12);
    font-size: 11px;
    color: var(--muted);
    background: rgba(var(--green-rgb), 0.04);
    flex-shrink: 0;
}

.model-picker-v2 .mp-footer strong {
    color: var(--green);
    font-weight: 700;
}

.model-picker-v2 .mp-hint {
    font-family: "Share Tech Mono", monospace;
    font-size: 10px;
    opacity: 0.6;
    letter-spacing: 0.12em;
}

.model-picker-empty {
    padding: 60px 20px;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
    font-style: italic;
}

/* ── Capability tip bubble (shown after model selection) ── */
.model-cap-tip {
    margin: 0 16px 8px;
    padding: 12px 14px;
    background: linear-gradient(180deg, rgba(var(--green-rgb), 0.1), rgba(var(--green-rgb), 0.02));
    border: 1px solid rgba(var(--green-rgb), 0.35);
    border-radius: 12px;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.22s ease, transform 0.22s ease;
    box-shadow: 0 4px 18px rgba(var(--green-rgb), 0.12);
}

.model-cap-tip.visible {
    opacity: 1;
    transform: translateY(0);
}

.model-cap-tip-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 8px;
    margin-bottom: 8px;
    border-bottom: 1px dashed rgba(var(--green-rgb), 0.2);
}

.model-cap-tip-icon {
    font-size: 18px;
    line-height: 1;
    flex-shrink: 0;
}

.model-cap-tip-label {
    flex: 1;
    font-size: 13px;
    font-weight: 700;
    color: var(--green);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.model-cap-tip-close {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--panel-2);
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: 16px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s;
}

.model-cap-tip-close:hover {
    background: rgba(var(--red-rgb), 0.15);
    color: var(--red);
    border-color: rgba(var(--red-rgb), 0.4);
}

.model-cap-tip-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.model-cap-tip-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text);
    line-height: 1.4;
}

.model-cap-tip-feature-icon {
    font-size: 14px;
    flex-shrink: 0;
    width: 16px;
    text-align: center;
}

@media (max-width: 600px) {
    .model-cap-tip {
        margin: 0 10px 8px;
        padding: 10px 12px;
    }
    .model-cap-tip-label {
        font-size: 11px;
    }
    .model-cap-tip-list li {
        font-size: 11px;
    }
}

/* ── Mobile ── */
@media (max-width: 600px) {
    /* Chained selector — see the 🔴 note at the top of this file for why
     * a bare `.model-picker-v2` gets stomped by the legacy `.model-picker`
     * rule further down. */
    .model-picker.model-picker-v2 {
        max-height: 94vh;
        max-width: 100%;
        width: 100%;
        border-radius: 16px 16px 0 0;
        align-self: flex-end;
    }
    .mp-header, .mp-search-row, .mp-chips, .mp-footer {
        padding-left: 14px;
        padding-right: 14px;
    }
    .mp-row {
        padding: 12px 10px;
    }
    .mp-row-copy {
        opacity: 0.6;
    }
    .mp-hint {
        display: none;
    }
    .mp-row-label {
        font-size: 13px;
    }
    .mp-row-id {
        font-size: 10px;
    }
    .mp-meta-pill {
        font-size: 9px;
        padding: 2px 6px;
    }
}

@media (max-width: 420px) {
    /* Hide context/price pills on very narrow screens — label+id is enough */
    .mp-meta {
        display: none;
    }
}

@keyframes overlayFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.model-picker {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 20px;
    width: 100%;
    max-width: 400px;
    max-height: 70vh;
    overflow-y: auto;
    animation: pickerSlideIn 0.2s ease-out;
}

@keyframes pickerSlideIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Mobile: turn modal into bottom sheet */
@media (max-width: 768px) {
    .model-picker-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .model-picker {
        max-width: 100%;
        max-height: 85vh;
        border-radius: 18px 18px 0 0;
        border-left: none;
        border-right: none;
        border-bottom: none;
        padding: 16px 16px 28px;
        animation: sheetSlideUp 0.22s ease-out;
        position: relative;
        padding-top: 26px;
    }

    .model-picker::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 44px;
        height: 4px;
        border-radius: 2px;
        background: var(--line);
    }

    @keyframes sheetSlideUp {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }
}

.model-picker-title {
    font-size: 15px;
    color: var(--green);
    margin-bottom: 16px;
    text-align: center;
}

.model-group-name {
    font-size: 12px;
    color: var(--green-dim);
    padding: 8px 0 4px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 4px;
}

.model-option {
    padding: 10px 12px;
    cursor: pointer;
    border-radius: 8px;
    font-size: 13px;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.model-option:hover {
    background: rgba(var(--green-rgb), 0.06);
}

.model-option.active {
    background: rgba(var(--green-rgb), 0.1);
    color: var(--green);
    border-left: 3px solid var(--green);
}

.model-option.locked {
    opacity: 0.4;
    cursor: not-allowed;
}

.model-option-name {
    flex: 1;
}

.model-option-icon {
    font-size: 15px;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.model-option-info {
    font-size: 10px;
    color: var(--muted);
    margin-top: 1px;
}

.model-option-badges {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.model-option-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(var(--amber-rgb), 0.15);
    color: var(--amber);
    white-space: nowrap;
}

.model-option-badge.free-badge {
    background: rgba(var(--green-rgb), 0.1);
    color: var(--green);
}

.model-option-badge.think-badge {
    background: rgba(0, 150, 255, 0.1);
    color: #4db8ff;
}

/* ── Toast notifications ── */
#toastContainer {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 16px;
    font-family: inherit;
    font-size: 13px;
    color: var(--text);
    min-width: 200px;
    max-width: 350px;
    pointer-events: auto;
    animation: toastSlideIn 0.3s ease;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.toast.error {
    border-color: rgba(var(--red-rgb), 0.4);
    color: var(--red);
}

.toast.success {
    border-color: rgba(var(--green-rgb), 0.3);
    color: var(--green);
}

.toast.info {
    border-color: rgba(0, 150, 255, 0.3);
    color: #4db8ff;
}

.toast.removing {
    animation: toastSlideOut 0.3s ease forwards;
}

@keyframes toastSlideIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastSlideOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(40px); }
}

/* ── Sidebar overlay for mobile ── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s;
}

.sidebar-overlay.visible {
    display: block;
    opacity: 1;
}

/* ── Network error bar ── */
.network-error-bar {
    background: rgba(var(--red-rgb), 0.12);
    border-bottom: 1px solid rgba(var(--red-rgb), 0.2);
    color: var(--red);
    font-size: 12px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.network-error-bar button {
    background: none;
    border: 1px solid rgba(var(--red-rgb), 0.3);
    color: var(--red);
    font-family: inherit;
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 6px;
    cursor: pointer;
}

.network-error-bar button:hover {
    background: rgba(var(--red-rgb), 0.1);
}

/* ── Viewport height fix for mobile browsers ── */
@supports (height: 100dvh) {
    html, body, #app {
        height: 100dvh;
    }
    .chat-layout {
        height: 100dvh;
    }
}

