/* Manage-models modal. Design language mirrors SettingsView's
   card-on-surface treatment (1px border, 14px radius, soft shadow
   in light mode). The overlay paints over the whole shell so the
   chat behind dims; click-outside closes. Max-width keeps long
   model ID strings from stretching the dialog on a wide viewport. */

.mmm__overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: grid;
  place-items: center;
  z-index: 1000;
  padding: 24px;
  box-sizing: border-box;
  /* Tap-anywhere-outside-to-close — we listen on the overlay's
     click handler in the component. */
}

[data-theme="light"] .mmm__overlay {
  background: rgba(15, 18, 25, 0.32);
}

.mmm {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 460px;
  /* dvh tracks the *visible* viewport under mobile browser chrome + the
     keyboard, so the footer buttons don't land below the fold; vh stays as
     the fallback for browsers without dvh. */
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  padding: 20px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 14px;
  color: var(--text);
}

[data-theme="light"] .mmm {
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.08),
    0 1px 3px rgba(0, 0, 0, 0.06);
}

.mmm__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mmm__title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

.mmm__close {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background 0.12s, color 0.12s;
}

.mmm__close:hover {
  background: var(--surface2);
  color: var(--text);
}

.mmm__subtext {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}

.mmm__section {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mmm__section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 4px 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.mmm__section-icon {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--surface);
  display: grid;
  place-items: center;
  color: var(--text);
  flex-shrink: 0;
}

.mmm__section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.mmm__rows {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mmm-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s;
}

.mmm-row:hover { background: var(--surface); }

.mmm-row--hidden .mmm-row__title,
.mmm-row--hidden .mmm-row__sub {
  opacity: 0.5;
}

.mmm-row__main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.mmm-row__title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
}

.mmm-row__sub {
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  line-height: 1.3;
  word-break: break-all;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Legacy pill — marks IDs that were in KNOWN_MODELS but the live
   API didn't return. Kept visible so chats that persisted them
   resolve, but the owner can recognize them at a glance. */
.mmm-row__pill {
  font-size: 10px;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  line-height: 1.4;
}

.mmm-row__toggle {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

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

.mmm__skeleton-row {
  height: 56px;
  border-radius: 12px;
  background: var(--surface2);
  opacity: 0.5;
  animation: mmm-skeleton-pulse 1.6s ease-in-out infinite;
}

@keyframes mmm-skeleton-pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 0.6; }
}

.mmm__error {
  margin: 0;
  font-size: 13px;
  color: var(--danger);
}

/* Inline discard-confirm — replaces window.confirm which iOS PWA suppresses.
   Mirrors the pendingSwitch confirm in ChatSettingsPanel. */
.mmm__confirm {
  background: color-mix(in srgb, var(--accent) 5%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--border));
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mmm__confirm-copy {
  margin: 0;
  font-size: 13px;
  color: var(--text);
  line-height: 1.4;
}

.mmm__confirm-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.mmm__foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
  padding-top: 14px;
}

.mmm__foot-spacer {
  flex: 1;
}

.mmm__btn {
  background: var(--accent);
  color: var(--bg);
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.12s, background 0.12s;
}

.mmm__btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.mmm__btn:not(:disabled):hover {
  opacity: 0.9;
}

.mmm__btn--outline {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.mmm__btn--outline:not(:disabled):hover {
  background: var(--surface2);
}

.mmm__btn--ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}

.mmm__btn--ghost:not(:disabled):hover {
  background: var(--surface2);
  color: var(--text);
}
