/* BananaWeb — shared controls: buttons, fields, chips, segments, dialogs, toasts, model picker. */

/* ─── Toasts ─────────────────────────────────────────────────────────────────
   Stacked so a second message does not erase the first. On phones they sit
   above the send button rather than on top of it. */

.toast-host {
  position: fixed;
  bottom: var(--sp-9);
  right: var(--sp-9);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  align-items: flex-end;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-4);
  max-width: min(360px, calc(100vw - var(--sp-10)));
  padding: var(--sp-5) var(--sp-6);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: var(--fs-md);
  line-height: var(--lh-normal);
  box-shadow: var(--shadow-md);
  pointer-events: auto;
  opacity: 0;
  transform: translateY(var(--sp-4));
  transition: opacity var(--dur-slow) var(--ease-out),
              transform var(--dur-slow) var(--ease-out);
}

.toast-in { opacity: 1; transform: translateY(0); }

.toast-leaving { opacity: 0; transform: translateY(var(--sp-2)); }

.toast-text { flex: 1; }

.toast-error   { border-left: 3px solid var(--danger); }

.toast-success { border-left: 3px solid var(--success); }

.toast-info    { border-left: 3px solid var(--accent); }

.toast-close {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--r-xs);
  background: transparent;
  color: var(--text-muted);
  font-size: var(--fs-xl);
  line-height: 1;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease),
              background var(--dur-fast) var(--ease);
}

.toast-close:hover { color: var(--text-primary); background: var(--bg-hover); }

/* ─── Touch targets ──────────────────────────────────────────────────────────
   These controls are 18-28px by design and the layouts depend on it, so the
   tappable area is enlarged with a pseudo-element instead of the box itself.
   Guideline minimum is 44px; this reaches it without moving anything. */

.icon-btn-sm,
.session-item-del,
.regen-btn,
.gallery-dl-btn,
.gallery-close,
.preview-thumb-del,
.toast-close {
  position: relative;
}

.icon-btn-sm::after,
.session-item-del::after,
.regen-btn::after,
.gallery-dl-btn::after,
.gallery-close::after,
.preview-thumb-del::after,
.toast-close::after {
  content: '';
  position: absolute;
  inset: 50% auto auto 50%;
  width: 44px;
  height: 44px;
  transform: translate(-50%, -50%);
}

@media (hover: hover) {
  /* Pointer users do not need the extra area and it can swallow hovers. */
  .icon-btn-sm::after,
    .session-item-del::after,
    .regen-btn::after,
    .gallery-dl-btn::after,
    .gallery-close::after,
    .preview-thumb-del::after,
    .toast-close::after { display: none; }
}

/* ─── Sidebar on short or narrow viewports ───────────────────────────────────
   The sidebar is a fixed-height flex column whose session list is the only
   scrolling part. That holds on a desktop, where the fixed blocks fit. On a
   phone they do not: the column was `overflow: hidden`, so flex children with
   the default shrink factor were squeezed instead — the "Новый чат" button
   collapsed from 36px to 18px and the footer was simply unreachable.

   Below, the whole drawer scrolls as one and nothing is allowed to shrink. */

.sidebar-header,
.page-nav,
.new-session-btn,
.sidebar-footer { flex-shrink: 0; }

@media (max-width: 768px), (max-height: 560px) {
  /* Controls stay comfortably tappable rather than compressing to fit. */
  .btn { padding: var(--sp-5) var(--sp-7); }
}

/* ─── Utility ────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: var(--fs-lg);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform var(--dur-fast);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn:active { transform: scale(0.97); }
.btn:disabled,
.btn:disabled:hover {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn-icon { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary {
  background: var(--accent);
  color: var(--text-on-accent);
  font-weight: 600;
  box-shadow: 0 0 0 0 var(--accent-glow);
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 16px var(--accent-glow);
}

.btn-accent {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}

.btn-accent:hover {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-full { width: 100%; justify-content: center; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}

.icon-btn svg { width: 18px; height: 18px; }

.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.icon-btn-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.icon-btn-sm svg { width: 15px; height: 15px; }

.icon-btn-sm:hover { background: var(--bg-hover); color: var(--text-primary); }

.select-field {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: var(--fs-md);
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238ba4be' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.select-field:focus { border-color: var(--accent); }

.icon { display: block; }

/* ─── Sprite icons ───────────────────────────────────────────────────────────
   templates/_icons.html holds the geometry; stroke and fill come from here so
   one symbol serves every weight. */
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg.icon {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
svg.icon-bold { stroke-width: 2.5; }

.section-label {
  display: block;
  font-size: var(--fs-2xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-family: var(--font-mono);
}

/* Section heading with an action on the right */

.section-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.section-label-row .section-label { margin-bottom: 6px; }

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  padding: 0 0 6px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color var(--transition);
}

.link-btn svg { width: 12px; height: 12px; }

.link-btn:hover:not(:disabled) { color: var(--accent); }

.link-btn:disabled { opacity: 0.5; cursor: default; }

.empty-icon {
  font-size: var(--fs-display);
  filter: drop-shadow(0 0 24px var(--accent-glow));
  animation: float 4s ease-in-out infinite;
}

@media (max-width: 768px) {
  .toast-host {
      right: var(--sp-4);
      left: var(--sp-4);
      bottom: calc(var(--sp-11) + env(safe-area-inset-bottom, 0px));
      align-items: stretch;
    }
  .toast { max-width: none; }
}

/* ─── Model description ──────────────────────────────────────────────────── */

/* Crossfade on model change: the node stays put, so only opacity can carry
   the change. */

.model-description.swapping { opacity: 0; }

.model-description {
  transition: opacity var(--dur-fast) var(--ease);
  margin-top: 7px;
  padding: 8px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  line-height: 1.5;
  animation: fadeIn var(--dur-mid) ease;
}

.size-btns {
  display: flex;
  position: relative;
  gap: 1px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 2px;
}

/* The selection itself, sliding between segments. Sized and placed by
   slideSegment(); zero-width until it has been measured. */

.seg-indicator {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 0;
  width: 0;
  border-radius: 5px;
  background: var(--accent-dim);
  transition: transform var(--dur-mid) var(--ease-out),
              width var(--dur-mid) var(--ease-out);
  pointer-events: none;
}

.size-btn {
  position: relative;
  z-index: 1;
  padding: 2px 8px;
  border-radius: 5px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  letter-spacing: 0.02em;
}

.size-btn:hover { color: var(--text-primary); }

.size-btn.active { color: var(--accent); }

/* Fallback for the first paint, before the indicator has been measured. */

.size-btns:not(.has-indicator) .size-btn.active { background: var(--accent-dim); }

/* Selectable, but the model does not advertise it — see applyModelCaps. */

.size-btn.untested,
.ar-opt.untested {
  opacity: 0.55;
  border-bottom: 1px dashed var(--text-muted);
}

/* Marks come and go on every model change; without this the whole parameter
   row flickered at each switch. */

.size-btn, .ar-opt, .ar-trigger, .unverified .param-label {
  transition: background var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease),
              opacity var(--dur-mid) var(--ease),
              border-color var(--dur-mid) var(--ease);
}

/* Option the currently selected model positively does not support */

.size-btn:disabled,
.ar-opt:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.size-btn:disabled:hover { color: var(--text-secondary); }

/* ─── Compact controls on touch ──────────────────────────────────────────────
   The "pick one of N" chips are 18-24px tall by design. On a pointer device
   that is fine; on a finger it is not. */

@media (hover: none) {
  .size-btn { padding-top: var(--sp-3); padding-bottom: var(--sp-3); }
}

/* Same sizing on a narrow window, where the pointer may still be a finger and
   the media query above cannot know it. */

@media (max-width: 768px) {
  /* An explicit height rather than guessed padding: these carry 10-11px text,
       so padding alone never reaches a comfortable target. */
  .size-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: var(--sp-2) var(--sp-5);
  }
}

/* ─── Danger button ──────────────────────────────────────────────────────── */
.btn-danger {
  background: var(--danger);
  color: var(--on-media);
  font-weight: 600;
}
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 85%, #fff); }

/* ─── Section value (right side of a section label row) ──────────────────── */
.section-value {
  margin-bottom: 6px;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--accent);
}

/* ─── Chips ──────────────────────────────────────────────────────────────────
   "Pick one of a few" pills. Were three copies — .ar-chip (video), .mode-chip
   and .audio-tag (audio) — with different padding and gaps. */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
}
.chip {
  padding: 3px 9px;
  border-radius: var(--r-xl);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.chip:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.chip.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}
/* Positively unsupported by the selected model. */
.chip:disabled,
.chip:disabled:hover {
  opacity: 0.3;
  background: transparent;
  color: var(--text-secondary);
  cursor: not-allowed;
}
@media (hover: none) {
  .chip { padding-top: var(--sp-3); padding-bottom: var(--sp-3); }
}
@media (max-width: 768px) {
  .chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: var(--sp-2) var(--sp-5);
  }
}

/* ─── Caps gating ────────────────────────────────────────────────────────────
   The model declares nothing for this control: silence, not a denial. The
   full menu stays, marked as unverified. */
.sidebar-section.caps-unverified .section-label { opacity: 0.65; }
.sidebar-section.caps-unverified .chip,
.sidebar-section.caps-unverified .select-field { border-style: dashed; }

/* ─── Dialog ─────────────────────────────────────────────────────────────────
   ui/dialog.js — replaces confirm() / prompt() and the old rename modal. */
.ui-dialog {
  margin: auto;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-primary);
  max-width: min(420px, calc(100vw - 32px));
  width: 100%;
  overflow: visible;
}
.ui-dialog::backdrop {
  background: var(--scrim);
  backdrop-filter: blur(4px);
  animation: fadeIn var(--dur-mid) ease;
}
.ui-dialog[open] .ui-dialog-box { animation: modalIn var(--dur-mid) var(--ease-out); }
.ui-dialog-box {
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
  padding: var(--sp-9);
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.ui-dialog-title {
  font-size: var(--fs-xl);
  font-weight: 600;
}
.ui-dialog-message {
  font-size: var(--fs-md);
  line-height: var(--lh-normal);
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}
.ui-dialog-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: var(--fs-lg);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.ui-dialog-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.ui-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-4);
  margin-top: var(--sp-2);
}

/* ─── Drop zone ──────────────────────────────────────────────────────────────
   ui/dropzone.js — one optional file: video frames, input audio. */
.dropzone-col {
  width: 108px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.dropzone {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  text-align: center;
  transition: border-color var(--transition), background var(--transition), opacity var(--transition);
  overflow: hidden;
  background: var(--bg-input);
  user-select: none;
}
.dropzone:hover,
.dropzone.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
}
.dropzone.has-file {
  border-style: solid;
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
}
.dropzone-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  line-height: 1.4;
  pointer-events: none;
}
.dropzone-placeholder svg { width: 24px; height: 24px; }
.dropzone-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.dropzone-clear {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: var(--scrim-strong);
  color: var(--on-media);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  z-index: 2;
  transition: background var(--dur-fast);
}
.dropzone-clear:hover { background: var(--danger); }
.dropzone-label {
  font-size: var(--fs-2xs);
  color: var(--text-muted);
  text-align: center;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
/* The model has no slot for this file. Still clickable: the click explains. */
.dropzone-col.disabled .dropzone {
  opacity: 0.4;
  cursor: not-allowed;
}
.dropzone-col.disabled .dropzone:hover {
  border-color: var(--border-strong);
  background: var(--bg-input);
  color: var(--text-muted);
}

/* ─── Model picker ───────────────────────────────────────────────────────────
   ui/model-picker.js. The trigger replaces the <select>; the panel opens in a
   <dialog> so it can overflow the sidebar and gets focus handling for free. */
.mp-trigger {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  padding: 8px 30px 9px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-ui);
  text-align: left;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.mp-trigger:hover { border-color: var(--border-strong); background: var(--bg-hover); }
.mp-trigger-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-4);
  min-width: 0;
}
.mp-trigger-name {
  font-size: var(--fs-md);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mp-trigger-by { font-size: var(--fs-xs); color: var(--text-muted); }
.mp-chevron {
  position: absolute;
  top: 14px;
  right: 12px;
  width: 12px;
  height: 8px;
  color: var(--text-secondary);
}
.mp-trigger .mp-badges { margin-top: 3px; }

.mp-badges { display: flex; flex-wrap: wrap; gap: 4px; }
.mp-badge {
  padding: 1px 6px;
  border-radius: var(--r-full);
  border: 1px solid var(--border-strong);
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  line-height: 1.5;
  color: var(--text-secondary);
  white-space: nowrap;
}
.mp-badge-good {
  color: var(--success);
  border-color: color-mix(in srgb, var(--success) 40%, transparent);
  background: color-mix(in srgb, var(--success) 10%, transparent);
}
.mp-badge-warn {
  color: var(--warning);
  border-color: color-mix(in srgb, var(--warning) 40%, transparent);
  background: color-mix(in srgb, var(--warning) 10%, transparent);
}
.mp-badge-muted { color: var(--text-muted); border-style: dashed; }

.mp-price {
  flex-shrink: 0;
  padding: 1px 7px;
  border-radius: var(--r-full);
  background: var(--accent-dim);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 600;
  white-space: nowrap;
}

.mp-dialog {
  position: fixed;
  inset: auto;
  margin: 0;
  padding: 0;
  width: min(560px, calc(100vw - 16px));
  max-height: min(72vh, 680px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.mp-dialog[open] { display: flex; animation: arPanelIn var(--dur-mid) var(--ease-out); }
.mp-dialog::backdrop { background: rgba(0, 0, 0, 0.18); }
.mp-panel { display: flex; flex-direction: column; min-height: 0; width: 100%; }
.mp-head {
  display: flex;
  gap: var(--sp-4);
  align-items: center;
  padding: var(--sp-5);
  border-bottom: 1px solid var(--border);
}
.mp-search {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: var(--fs-md);
  outline: none;
}
.mp-search:focus { border-color: var(--accent); }
.mp-sort {
  width: auto;
  padding: 7px 28px 7px 10px;
  background-color: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238ba4be' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}
.mp-compare-btn { padding: 7px 12px; font-size: var(--fs-sm); }
.mp-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
}
.mp-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--sp-2) var(--sp-3) var(--sp-4);
  outline: none;
}
.mp-group {
  padding: var(--sp-5) var(--sp-4) var(--sp-2);
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.mp-row {
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-left: 2px solid transparent;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-ui);
  text-align: left;
  cursor: pointer;
}
.mp-row.active { background: var(--bg-hover); }
.mp-row.selected { border-left-color: var(--accent); background: var(--accent-dim); }
.mp-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.mp-row-title { display: flex; align-items: baseline; gap: var(--sp-3); min-width: 0; }
.mp-row-name { font-size: var(--fs-md); font-weight: 500; }
.mp-row-by { font-size: var(--fs-xs); color: var(--text-muted); }
.mp-empty { padding: var(--sp-9); text-align: center; color: var(--text-muted); font-size: var(--fs-md); }
.mp-foot {
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--border);
  font-size: var(--fs-xs);
  line-height: 1.45;
  color: var(--text-muted);
}
@media (max-width: 768px) {
  /* A bottom sheet on a phone. */
  .mp-dialog {
    inset: auto 0 0 0;
    width: 100%;
    max-width: 100%;
    max-height: 86vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mp-head { flex-wrap: wrap; }
  .mp-search { flex-basis: 100%; }
  .mp-row { padding: 10px; }
}

/* ─── Model comparison ───────────────────────────────────────────────────── */
.mp-compare {
  margin: auto;
  padding: 0;
  width: min(1100px, calc(100vw - 24px));
  max-height: 86vh;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.mp-compare::backdrop { background: var(--scrim); backdrop-filter: blur(3px); }
.mp-compare-box { display: flex; flex-direction: column; max-height: 86vh; }
.mp-compare-head {
  display: flex;
  align-items: center;
  gap: var(--sp-6);
  padding: var(--sp-6) var(--sp-7);
  border-bottom: 1px solid var(--border);
}
.mp-compare-head h3 { font-size: var(--fs-xl); font-weight: 600; white-space: nowrap; }
.mp-compare-head .mp-search { max-width: 280px; }
.mp-compare-head .icon-btn { margin-left: auto; }
.mp-compare-scroll { overflow: auto; flex: 1; min-height: 0; }
.mp-table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: var(--fs-sm); }
.mp-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-strong);
  padding: 0;
  text-align: left;
  white-space: nowrap;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.mp-table th:first-child { padding: 10px 14px; left: 0; z-index: 3; }
.mp-th {
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  text-align: left;
  cursor: pointer;
}
.mp-th:hover { color: var(--text-primary); }
.mp-th[aria-sort="ascending"]::after { content: ' ↑'; color: var(--accent); }
.mp-th[aria-sort="descending"]::after { content: ' ↓'; color: var(--accent); }
.mp-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  white-space: nowrap;
  color: var(--text-secondary);
}
.mp-table td.yes { color: var(--success); font-weight: 700; }
/* Colour, not opacity: opacity also faded the row's hover and selection. */
.mp-table td.no { color: color-mix(in srgb, var(--text-muted) 60%, transparent); }
.mp-table td.mp-td-name {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--bg-surface);
  font-family: var(--font-ui);
  white-space: normal;
  min-width: 190px;
}
.mp-td-name .mp-row-name,
.mp-td-name .mp-row-by { display: block; }
.mp-table tbody tr { cursor: pointer; }
.mp-table tbody tr:hover td { background: var(--bg-hover); }
.mp-table tbody tr.selected td { background: var(--accent-dim); }
.mp-compare-legend {
  padding: var(--sp-5) var(--sp-7);
  border-top: 1px solid var(--border);
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

/* ─── Cost estimate ──────────────────────────────────────────────────────── */
.cost-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: var(--r-full);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  background: var(--accent-dim);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 600;
  white-space: nowrap;
  cursor: help;
}

/* ─── Shortcut help ──────────────────────────────────────────────────────── */
.shortcut-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--sp-4) var(--sp-7);
  align-items: baseline;
  font-size: var(--fs-md);
}
.shortcut-list dt { white-space: nowrap; color: var(--text-muted); }
.shortcut-list dd { color: var(--text-secondary); }
.shortcut-list kbd {
  display: inline-block;
  padding: 0 6px;
  margin: 0 2px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: var(--r-xs);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
}
