/* Match Library — stage 2. Dense tactical list built on the shared tokens. */

.match-library { min-width: 0; }
.match-library__header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}
.match-library__heading { min-width: 0; }
.match-library__eyebrow {
  margin: 0 0 4px;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: var(--font-weight-medium);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.match-library__header h1 {
  margin: 0;
  color: var(--color-text);
  font-family: var(--font-display);
  font-size: 28px;
  line-height: 0.95;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}
.match-library__header p {
  max-width: 520px;
  margin: 4px 0 0;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  line-height: 1.4;
}
.match-library__header > .ui-button { min-height: 34px; padding-inline: 14px; }
.match-library__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}
.match-library__actions .ui-button { min-height: 34px; padding-inline: 14px; }
.match-library__sync-status {
  margin: -4px 0 10px;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  line-height: 1.35;
}
.match-library__sync-status.is-error { color: var(--color-danger, #e35d6a); }
#steam-sync-btn .htmx-indicator { display: none; }
#steam-sync-btn.htmx-request .htmx-indicator { display: inline; }
#steam-sync-btn.htmx-request .htmx-indicator-hide { display: none; }

/* ---- metrics as one scoreboard strip (not 4 soft SaaS cards) ----------- */
.match-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  margin-bottom: 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: rgba(13, 20, 30, 0.72);
  overflow: hidden;
}
.match-metric {
  display: flex;
  min-width: 0;
  min-height: 52px;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 0;
  border-right: 1px solid var(--color-border-soft);
  border-radius: 0;
  background: transparent;
}
.match-metric:last-child { border-right: 0; }
.match-metric__icon {
  display: grid;
  width: 28px;
  height: 28px;
  flex: none;
  place-items: center;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
  color: #9ca9b7;
}
.match-metric__icon .icon-asset {
  width: 14px;
  height: 14px;
}
.match-metric__icon--ready { color: var(--color-success); border-color: rgba(95, 212, 107, .22); background: transparent; }
.match-metric__icon--steam { color: #b8d4ef; }
.match-metric__icon--processing { color: var(--color-primary); border-color: rgba(255, 106, 18, .28); background: transparent; }
.match-metric__body { display: grid; min-width: 0; gap: 2px; }
.match-metric__body > span {
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.match-metric__body > strong {
  color: var(--color-text);
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 1;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

/* ---- tabs and filters --------------------------------------------------- */
.match-library__workspace {
  min-width: 0;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  overflow: visible;
}
.match-source-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  padding: 0 10px;
  border-bottom: 1px solid var(--color-border-soft);
  overflow-x: auto;
  scrollbar-width: none;
}
.match-source-tabs::-webkit-scrollbar { display: none; }
.match-source-tab {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  min-height: 36px;
  align-items: center;
  gap: 6px;
  padding: 0 9px;
  color: var(--color-text-secondary);
  font-size: 10px;
  font-weight: var(--font-weight-bold);
  white-space: nowrap;
}
.match-source-tab:hover { color: var(--color-text); }
.match-source-tab.is-active { color: #fff; }
.match-source-tab.is-active::after {
  content: "";
  position: absolute;
  right: 8px;
  bottom: -1px;
  left: 8px;
  height: 2px;
  background: var(--color-primary);
}
.match-source-tab b {
  min-width: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: var(--color-text-muted);
  font-size: 8px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.match-filters {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) 130px 130px 170px auto auto auto;
  align-items: end;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--color-border-soft);
  background: var(--color-bg-elevated);
}
.match-filter { display: grid; min-width: 0; gap: 3px; }
.match-filter > span {
  color: var(--color-text-muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.match-filter .ui-input,
.match-filter .ui-select { min-height: 32px; height: 32px; }
.match-filter--search { align-self: end; }
.match-favorite-filter {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  font-size: var(--text-xs);
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.match-favorite-filter:hover,
.match-favorite-filter.is-active { border-color: rgba(245, 197, 66, 0.3); color: #f3d777; }
.match-favorite-filter input { accent-color: var(--color-warning); }
.match-select-toggle {
  display: inline-flex;
  min-width: max-content;
  height: 32px;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-secondary);
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 700;
  cursor: pointer;
}
.match-select-toggle:hover { color: var(--color-text); background: var(--color-surface-raised); }
.match-select-toggle.is-active {
  border-color: rgba(255, 101, 15, 0.45);
  background: var(--color-primary-soft);
  color: #ffd1bb;
}
.match-view-toggle {
  display: inline-flex;
  min-width: max-content;
  height: 32px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.match-view-toggle label {
  display: inline-flex;
  min-width: 34px;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: var(--color-text-muted);
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
}
.match-view-toggle .icon-asset { width: 15px; height: 15px; }
.match-view-toggle label + label { border-left: 1px solid var(--color-border); }
.match-view-toggle label.is-active { background: var(--color-surface-raised); color: #fff; box-shadow: inset 0 -1px var(--color-primary); }
.match-view-toggle input { position: absolute; opacity: 0; pointer-events: none; }

.match-bulkbar {
  position: fixed;
  z-index: calc(var(--z-sticky) + 5);
  left: 50%;
  bottom: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 10px 14px;
  border: 1px solid rgba(255, 85, 0, 0.35);
  border-radius: var(--radius-md);
  background: rgba(18, 26, 38, 0.96);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
  color: var(--color-text);
  font-size: var(--text-sm);
  transform: translateX(-50%);
}
.match-bulkbar .ui-button { min-height: 34px; }

/* ---- list header and rows ------------------------------------------------ */
.match-results {
  min-width: 0;
  opacity: 1;
  transform: translateY(0);
  transition: opacity .22s ease, transform .22s ease;
}
.match-results--entering { opacity: 0; transform: translateY(4px); }
.match-results--no-motion { transition: none; }
@media (prefers-reduced-motion: reduce) {
  .match-results { transform: none; transition: none; }
}
.match-table-head,
.library-match-row {
  --library-col-result: 96px;
  --library-col-date: 8.5rem;   /* DD.MM.YYYY + HH:mm; rem stays stable under zoom */
  --library-col-score: 92px;
  --library-col-kda: 112px;
  --library-col-rating: 72px;
  --library-col-hsadr: 72px;
  --library-col-source: 96px;
  --library-col-actions: 168px;
  --library-col-select: 24px;
  display: grid;
  /* MAP uses minmax(0, 1fr) on purpose: minmax(200px, 1fr) lets long titles
     inflate the track per-row (min-content), so ADDED/SCORE drift when zoom
     changes subpixel rounding. Thumb + ellipsis keep the map cell readable. */
  grid-template-columns:
    var(--library-col-result)
    minmax(0, 1fr)
    var(--library-col-date)
    var(--library-col-score)
    var(--library-col-kda)
    var(--library-col-rating)
    var(--library-col-hsadr)
    var(--library-col-source)
    var(--library-col-actions);
  align-items: center;
  column-gap: 12px;
  width: 100%;
}
.match-table-head.is-selecting,
.library-match-row.is-selecting {
  grid-template-columns:
    var(--library-col-select)
    var(--library-col-result)
    minmax(0, 1fr)
    var(--library-col-date)
    var(--library-col-score)
    var(--library-col-kda)
    var(--library-col-rating)
    var(--library-col-hsadr)
    var(--library-col-source)
    var(--library-col-actions);
}
.match-table-head {
  min-height: 34px;
  padding: 0 14px;
  border-bottom: 1px solid var(--color-border-soft);
  color: var(--color-text-muted);
  font-size: 10px;
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.match-table-head > span { min-width: 0; }
.match-table-head__result,
.match-table-head__map,
.match-table-head__date,
.match-table-head__source,
.match-table-head__actions { text-align: left; justify-self: start; }
.match-table-head__score,
.match-table-head__kda,
.match-table-head__rating,
.match-table-head__hsadr { text-align: center; justify-self: center; }
.library-match-row {
  position: relative;
  min-height: 64px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border-soft);
  background: var(--color-surface);
  transition: background 0.15s ease;
}
.library-match-row:hover { background: var(--color-surface-raised); }
.library-match-row:last-of-type { border-bottom-color: transparent; }
.library-match-row__select {
  display: none;
  place-items: center;
}
.library-match-row.is-selecting > .library-match-row__select { display: grid; }
.library-match-row__select input { width: 15px; height: 15px; accent-color: var(--color-primary); cursor: pointer; }
.library-match-row__map { display: flex; min-width: 0; align-items: center; gap: 12px; }
.library-match-thumb {
  display: block;
  width: 76px;
  height: 44px;
  flex: 0 0 auto;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-sm);
  background: var(--color-bg-elevated);
  overflow: hidden;
}
.library-match-thumb img { width: 100%; height: 100%; object-fit: cover; opacity: 0.88; }
.library-match-thumb img.library-match-thumb__fallback { object-fit: contain; padding: 10px; opacity: 0.48; filter: brightness(0) invert(1); }
.library-match-row__identity { min-width: 0; flex: 1 1 auto; }
.library-match-row__titleline { display: flex; min-width: 0; align-items: center; gap: 6px; }
.library-match-row__titleline > a,
.library-match-row__titleline > span {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: var(--color-text);
  font-size: 15px;
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.library-match-row__titleline > a:hover { color: #fff; text-decoration: underline; }
.library-match-row__identity > span {
  display: block;
  margin-top: 3px;
  color: var(--color-text-muted);
  font-size: 12px;
  line-height: 1.25;
}
.library-match-rename { display: flex; min-width: 0; align-items: center; gap: 6px; }
.library-match-rename .ui-input { min-width: 0; height: 34px; min-height: 34px; }
.library-match-rename .ui-button { min-height: 34px; padding: 0 10px; font-size: 11px; }
.library-match-row__date {
  display: grid;
  gap: 2px;
  justify-items: start;
  align-content: center;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  color: var(--color-text-secondary);
  font-size: 12px;
  line-height: 1.2;
}
.library-match-row__date > span { display: none; color: var(--color-text-muted); font-size: 10px; letter-spacing: 0.04em; text-transform: uppercase; }
.library-match-row__date strong {
  margin-top: 0;
  max-width: 100%;
  overflow: hidden;
  color: var(--color-text);
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.library-match-row__date small {
  max-width: 100%;
  overflow: hidden;
  color: var(--color-text-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.match-table-head__date {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.library-match-row__score { display: grid; justify-items: center; gap: 4px; color: var(--color-text-muted); text-align: center; }
.library-match-row__result {
  display: grid;
  place-items: center start;
  color: var(--color-text-muted);
  text-align: left;
}
.library-score {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.library-score__n {
  color: #e8eef4;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.library-score__n.is-win { color: #6fbf7c; }
.library-score__n.is-loss { color: #d97880; }
.library-score__n.is-draw { color: var(--color-text-secondary); }
.library-score__n.is-muted { color: #9aa8b5; }
.library-score__n.is-opp-win { color: #6fbf7c; }
.library-score__sep {
  display: inline-block;
  color: var(--color-text-muted);
  font-family: var(--font-display);
  font-size: 18px;
  font-style: normal;
  font-weight: 600;
  line-height: 1;
}
.library-score__sep::before { content: ":"; }
.library-score--empty,
.library-score-fallback {
  color: var(--color-text);
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.library-kda,
.library-rating,
.library-hsadr {
  display: grid;
  justify-items: center;
  gap: 4px;
  min-width: 0;
  text-align: center;
}
.library-kda__vals {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.library-kda__vals b { font-size: 16px; font-weight: var(--font-weight-bold); }
.library-kda__vals i { color: var(--color-text-muted); font-style: normal; font-size: 12px; }
.library-kda__vals .is-k { color: #6fbf7c; }
.library-kda__vals .is-d { color: #d97880; }
.library-kda__vals .is-a { color: #9aa8b5; }
.library-kda > small,
.library-rating > small {
  color: var(--color-text-muted);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.library-rating > strong {
  display: inline-flex;
  min-width: 52px;
  height: 26px;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  border: 1px solid rgba(111, 191, 124, 0.4);
  border-radius: 6px;
  background: rgba(111, 191, 124, 0.1);
  color: #6fbf7c;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.library-rating > strong.is-low {
  border-color: rgba(217, 120, 128, 0.4);
  background: rgba(217, 120, 128, 0.1);
  color: #d97880;
}
.library-hsadr {
  gap: 5px;
}
.library-hsadr > span {
  display: grid;
  gap: 1px;
  justify-items: center;
  line-height: 1.05;
}
.library-hsadr b {
  color: #c5d0db;
  font-size: 14px;
  font-weight: var(--font-weight-bold);
  font-variant-numeric: tabular-nums;
}
.library-hsadr small {
  color: var(--color-text-muted);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.library-stat--empty {
  color: var(--color-text-muted);
  font-size: 14px;
}
.library-result {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--color-text-muted);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0;
  line-height: 1;
  text-transform: none;
  white-space: nowrap;
}
.library-result .icon-asset {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  color: inherit;
}
.library-result--win { color: #6fbf7c; }
.library-result--loss { color: #d97880; }
.library-result--draw { color: var(--color-text-secondary); }
.library-result--unknown {
  font-weight: var(--font-weight-regular);
  color: var(--color-text-muted);
}
.library-result--spectator {
  color: #8fa0b0;
  font-weight: var(--font-weight-medium);
  letter-spacing: 0.02em;
}
.library-match-row--spectator {
  background: rgba(12, 18, 26, 0.9);
}
.library-match-row--spectator:hover {
  background: var(--color-surface-raised);
}
.library-grid-card--spectator .library-grid-card__visual > img {
  opacity: 0.58;
}
.library-grid-card__score .library-result {
  margin-left: 4px;
  font-size: 12px;
}
.library-processing-label {
  color: var(--color-text);
  font-size: 11px;
  font-weight: var(--font-weight-semibold);
  line-height: 1.2;
}
.library-parse-progress {
  display: grid;
  justify-items: center;
  gap: 5px;
  min-width: 96px;
  max-width: 140px;
}
.library-parse-progress--indeterminate {
  min-width: 110px;
  max-width: 150px;
}
.library-parse-progress__track {
  position: relative;
  display: block;
  width: 100%;
  height: 3px;
  border-radius: var(--radius-pill);
  background: var(--color-border);
  overflow: hidden;
}
.library-parse-progress__track > i {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  border-radius: inherit;
  background: var(--color-primary);
  transition: width 0.35s ease;
}
.library-parse-progress__pct {
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.04em;
}
.library-indeterminate {
  position: relative;
  display: block;
  width: 72px;
  height: 3px;
  border-radius: var(--radius-pill);
  background: var(--color-border);
  overflow: hidden;
}
.library-indeterminate i {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -45%;
  width: 45%;
  background: var(--color-primary);
  animation: library-progress 1.2s ease-in-out infinite;
}
@keyframes library-progress { to { left: 100%; } }
.library-match-row__source { display: grid; min-width: 0; align-content: center; justify-items: start; gap: 4px; color: var(--color-text-secondary); }
.source-item { display: inline-flex; min-width: 0; align-items: center; gap: 5px; color: var(--color-text-secondary); font-size: 11px; }
.source-item > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-item .icon-asset { width: 14px; height: 14px; }
.source-item-steam { color: #9fcdf6; }
.source-item-manual { color: #d7a17f; }
.source-item-faceit { color: #d7bb68; }
.source-item-voice,
.source-item-available { color: #79cfc5; }
.source-item-expired { color: var(--color-warning, #e0b84a); }
.library-match-row__actions {
  display: grid;
  min-width: 0;
  width: 100%;
  grid-template-columns: minmax(0, 1fr) 34px 34px;
  align-items: center;
  justify-content: stretch;
  gap: 6px;
}
.library-match-row__actions .ui-button { min-height: 34px; height: 34px; padding: 0 10px; font-size: 11px; }
.library-main-action { width: 100%; border-color: var(--color-border-strong); background: #111923; color: #d5dde5; }
.library-main-action .icon-asset { width: 13px; height: 13px; }
.library-main-action--open { border-color: rgba(255, 101, 15, .52); background: transparent; color: #ffd1bb; }
.library-main-action--open:hover { border-color: var(--color-primary); background: var(--color-primary); color: #fff; }
.library-main-action--import { border-color: #34465c; background: #0f1720; color: #aeb9c5; }
.library-main-action--import:hover { border-color: #586f89; background: #17212d; color: #fff; }
.library-2d-button { width: 34px; height: 34px; border-color: rgba(47, 212, 196, 0.25); background: #0b1719; color: var(--color-teal); }
.library-2d-button:hover { border-color: var(--color-teal); background: var(--color-teal-soft); }
.library-2d-button .icon-asset { width: 15px; height: 15px; }
.library-2d-button:disabled { cursor: default; opacity: .35; }
.library-more-button { width: 34px; padding: 0 !important; color: var(--color-text-secondary); }
.library-more-button .icon-asset { width: 15px; height: 15px; }
.library-more-button:hover { color: var(--color-text); background: var(--color-surface-hover); }
.library-action-spacer { width: 34px; height: 34px; }
.library-pending-import { display: flex; min-width: 0; width: 100%; }
.library-pending-import > .ui-button { width: 100%; min-height: 34px; height: 34px; }

/* ---- action menu -------------------------------------------------------- */
.library-action-menu { position: relative; }
.library-action-menu__panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: var(--z-sticky);
  display: grid;
  width: 190px;
  padding: 5px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-bg-elevated);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45);
}
.library-action-menu__panel button {
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-secondary);
  font-size: var(--text-xs);
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}
.library-action-menu__panel button:hover { background: var(--color-surface-hover); color: var(--color-text); }
.library-action-menu__panel button.is-danger { color: #ff9a9a; }

/* ---- series ------------------------------------------------------------- */
.library-series-maps {
  grid-column: 2 / -1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  margin: 7px -14px -7px;
  padding: 0 14px 0 38px;
  border-top: 1px solid var(--color-border-soft);
  background: var(--color-bg-elevated);
}
.library-series-maps article {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) minmax(88px, auto);
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 46px;
  padding: 5px 0;
  border: 0;
  border-bottom: 1px solid var(--color-border-soft);
  border-radius: 0;
  background: transparent;
}
.library-series-maps article:last-child { border-bottom: 0; }
.library-series-maps img { width: 54px; height: 34px; border-radius: 4px; object-fit: cover; }
.library-series-maps div { min-width: 0; }
.library-series-maps strong,
.library-series-maps span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.library-series-maps strong { color: var(--color-text); font-size: var(--text-xs); }
.library-series-maps span { color: var(--color-text-muted); font-size: 10px; }
.library-series-maps a { justify-self: end; color: var(--color-teal); font-size: 10px; font-weight: 800; }

/* ---- pending Steam rows -------------------------------------------------
   A pending row IS a .library-match-row (same grid / height / padding / hover
   / dividers). Its map/date/teams/score cells are injected by htmx into a
   display:contents wrapper so they flow into the exact same shared columns as
   an imported match. Only the source badge and the Import action differ. */
.library-pending-meta { display: contents; }
/* The form wraps its single Import button; keep it a normal flex item (not
   display:contents) so the mobile touch-target rules can reach the button. */
.library-match-row--pending .library-pending-import > .ui-button {
  border-color: #34465c;
  background: #0f1720;
  color: #aeb9c5;
}
.library-match-row--pending .library-pending-import > .ui-button:hover {
  border-color: #586f89;
  background: #17212d;
  color: #fff;
}
.library-pending-refresh {
  margin-left: 5px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-text-secondary);
  font: inherit;
  font-weight: var(--font-weight-semibold);
  text-decoration: underline;
  cursor: pointer;
}
.library-pending-refresh:hover { color: var(--color-primary); }

/* ---- grid compatibility ------------------------------------------------- */
.match-results--grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
}
.library-grid-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-md);
  background: var(--color-bg-elevated);
  overflow: visible;
}
.library-grid-card__visual {
  position: relative;
  display: block;
  height: 112px;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  background: var(--color-surface-raised);
  overflow: hidden;
}
.library-grid-card__visual > img { width: 100%; height: 100%; object-fit: cover; opacity: .74; }
.library-grid-card__visual > img.library-grid-card__fallback { object-fit: contain; padding: 38px; filter: brightness(0) invert(1); opacity: .36; }
.library-grid-card__visual > span {
  position: absolute;
  left: 9px;
  bottom: 8px;
  padding: 3px 7px;
  border-radius: var(--radius-pill);
  background: rgba(7, 11, 17, .86);
  color: var(--color-text);
  font-size: 10px;
  font-weight: 800;
}
.library-grid-card__body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  padding: 11px;
}
.library-grid-card__topline { display: flex; min-width: 0; align-items: center; gap: 6px; }
.library-grid-card__topline input { accent-color: var(--color-primary); }
.library-grid-card__topline time { display: grid; margin-left: auto; color: var(--color-text-muted); white-space: nowrap; }
.library-grid-card__topline time strong { color: var(--color-text); font-size: 10px; line-height: 1.15; }
.library-grid-card__topline time small { font-size: 9px; line-height: 1.15; }
.library-grid-card__title { display: block; margin-top: 11px; overflow: hidden; color: var(--color-text); font-size: var(--text-lg); font-weight: var(--font-weight-bold); text-overflow: ellipsis; white-space: nowrap; }
.match-table-head__select { display: none; }
.match-table-head.is-selecting > .match-table-head__select { display: block; }
.library-grid-card__select { display: none; align-items: center; }
.library-grid-card.is-selecting .library-grid-card__select { display: inline-flex; }
.library-grid-card__select input { width: 15px; height: 15px; accent-color: var(--color-primary); cursor: pointer; }
.library-grid-card__stats {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) auto minmax(0, 0.9fr);
  align-items: center;
  gap: 10px;
  min-height: 52px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--color-border-soft);
}
.library-grid-card__stats .library-kda,
.library-grid-card__stats .library-rating,
.library-grid-card__stats .library-hsadr { justify-items: start; text-align: left; }
.library-grid-card__teams { display: none; }

.library-grid-card__score { display: flex; min-height: 44px; align-items: center; justify-content: center; gap: 9px; margin: 10px 0; border-block: 1px solid var(--color-border-soft); }
.library-grid-card__score strong { color: var(--color-text); font-size: 20px; font-weight: var(--font-weight-bold); font-variant-numeric: tabular-nums; }
.library-grid-card__score > span:first-child { color: var(--color-text-secondary); font-size: var(--text-xs); }
.library-series-toggle { padding: 0; border: 0; background: none; color: var(--color-teal); font-size: var(--text-xs); font-weight: 800; cursor: pointer; }
.library-grid-series { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.library-grid-series span { padding: 4px 6px; border-radius: var(--radius-sm); background: var(--color-surface); color: var(--color-text-secondary); font-size: 10px; }
.library-grid-series b { color: var(--color-text); }
.library-grid-card__actions { display: flex; align-items: center; gap: 6px; margin-top: auto; padding-top: 11px; }
.library-grid-card__actions > .ui-button { flex: 1; min-height: 36px; }
.library-grid-card__actions .library-action-menu { margin-left: auto; }
.library-grid-card--pending { display: flex; min-height: 0; flex-direction: column; }
.library-grid-card__body--pending { display: flex; flex: 1 1 auto; flex-direction: column; }
.library-grid-card__visual--pending { cursor: default; }
.library-grid-card__pending-state {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.library-grid-card__pending-state > span {
  display: grid;
  min-width: 0;
  gap: 4px;
  padding: 9px 10px;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
}
.library-grid-card__pending-state small {
  color: var(--color-text-muted);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.library-grid-card__pending-state strong {
  overflow: hidden;
  color: var(--color-text-secondary);
  font-size: 12px;
  font-weight: var(--font-weight-semibold);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.library-grid-card__pending-state strong.is-available { color: #79cfc5; }
.library-grid-card__pending-state strong.is-unavailable { color: var(--color-warning, #e0b84a); }
.library-grid-card__actions--pending { margin-top: auto; padding-top: 11px; }
.library-grid-card__actions--pending .library-pending-import { flex: 1 1 auto; }

.match-load-more { grid-column: 1 / -1; padding: 12px; text-align: center; }
.match-empty { grid-column: 1 / -1; display: grid; justify-items: center; padding: 52px 20px; text-align: center; }
.match-empty img { width: 30px; height: 30px; margin-bottom: 12px; filter: brightness(0) invert(1); opacity: .45; }
.match-empty strong { color: var(--color-text); font-size: var(--text-lg); }
.match-empty p { max-width: 430px; margin: 6px 0 16px; color: var(--color-text-secondary); font-size: var(--text-sm); }

/* ---- upload modal ------------------------------------------------------- */
.upload-modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-drawer);
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(2, 5, 9, 0.82);
}
.upload-dialog {
  width: min(760px, 100%);
  max-height: calc(100dvh - 40px);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  overflow-y: auto;
}
.upload-dialog__header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 18px 20px; border-bottom: 1px solid var(--color-border-soft); }
.upload-dialog__eyebrow { color: var(--color-primary); font-size: 9px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.upload-dialog__header h2 { margin: 3px 0 0; color: var(--color-text); font-size: var(--text-lg); line-height: 1.2; font-weight: var(--font-weight-bold); }
.upload-dialog__header p { margin: 5px 0 0; color: var(--color-text-secondary); font-size: var(--text-xs); }
.upload-dialog__close { min-height: 36px; padding: 0 10px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-bg-elevated); color: var(--color-text-secondary); font-size: var(--text-xs); font-weight: 700; cursor: pointer; }
.upload-dialog form { padding: 16px 20px 18px; }
.upload-dialog__section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.upload-dialog__section-head strong { color: var(--color-text); font-size: var(--text-sm); }
.upload-dialog__section-head span { color: var(--color-text-muted); font-size: var(--text-xs); }
.upload-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin: 0; padding: 0; border: 0; }
.upload-mode { position: relative; display: block; padding: 12px; border: 1px solid var(--color-border-soft); border-radius: var(--radius-sm); background: var(--color-bg-elevated); cursor: pointer; transition: border-color .15s ease, background .15s ease; }
.upload-mode:hover { border-color: var(--color-border-strong); background: var(--color-surface-raised); }
.upload-mode:has(input:checked) { border-color: rgba(255, 85, 0, .55); background: var(--color-surface-raised); box-shadow: inset 2px 0 0 var(--color-primary); }
.upload-mode:focus-within { outline: 2px solid rgba(255, 85, 0, .35); outline-offset: 2px; }
.upload-mode input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-modes strong { display: block; color: var(--color-text); font-size: var(--text-sm); }
.upload-modes span { display: block; margin-top: 3px; color: var(--color-text-secondary); font-size: var(--text-xs); font-weight: var(--font-weight-medium); }
.upload-modes p { margin: 7px 0 0; color: var(--color-text-secondary); font-size: var(--text-xs); line-height: 1.45; }
.upload-dropzone-new { display: flex; min-height: 150px; align-items: center; justify-content: center; flex-direction: column; margin-top: 10px; padding: 18px; border: 1px dashed var(--color-border-strong); border-radius: var(--radius-sm); background: var(--color-bg-elevated); text-align: center; cursor: pointer; }
.upload-dropzone-new:hover { border-color: var(--color-primary); background: var(--color-primary-soft); }
.upload-dropzone-new__icon { width: 30px; height: 30px; margin-bottom: 8px; color: var(--color-text-secondary); }
.upload-dropzone-new > strong { color: var(--color-text); font-size: var(--text-lg); }
.upload-dropzone-new > span { margin-top: 4px; color: var(--color-text-secondary); font-size: var(--text-xs); }
.upload-dropzone-new > .ui-button { margin-top: 12px; color: var(--color-text); }
.upload-file-summary { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-files {
  margin-top: 10px;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-sm);
  background: var(--color-bg-elevated);
  overflow: hidden;
}
.upload-files[hidden] { display: none; }
.upload-files > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
  padding: 0 11px;
  border-bottom: 1px solid var(--color-border-soft);
}
.upload-files > header strong { color: var(--color-text-secondary); font-size: var(--text-xs); }
.upload-files > header span { color: var(--color-text-muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.upload-files ol { max-height: 138px; margin: 0; padding: 0; list-style: none; overflow-y: auto; }
.upload-files li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 11px;
  border-bottom: 1px solid var(--color-border-soft);
}
.upload-files li:last-child { border-bottom: 0; }
.upload-files li b { color: var(--color-primary); font-size: 9px; font-variant-numeric: tabular-nums; }
.upload-files li span { overflow: hidden; color: var(--color-text); font-size: var(--text-xs); text-overflow: ellipsis; white-space: nowrap; }
.upload-files li small { color: var(--color-text-muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.upload-title-field { display: grid; gap: 5px; margin-top: 11px; }
.upload-title-field > span { color: var(--color-text-secondary); font-size: var(--text-xs); font-weight: 700; }
.upload-progress { margin-top: 12px; padding: 11px; border: 1px solid var(--color-border-soft); border-radius: var(--radius-md); background: var(--color-bg-elevated); }
.upload-progress__head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 7px; color: var(--color-text-secondary); font-size: var(--text-xs); }
.upload-progress__head b { color: var(--color-text); font-variant-numeric: tabular-nums; }
.ui-progress__bar.is-error { background: var(--color-danger); }
.upload-dialog__footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

/* 1280–1399px: retain the dense table using tighter columns. */
@media (min-width: 1280px) and (max-width: 1399px) {
  .match-filters { grid-template-columns: minmax(160px, 1fr) 120px 130px 180px; }
  .match-favorite-filter, .match-view-toggle, .match-select-toggle { grid-row: 2; }
  .match-table-head,
  .library-match-row {
    --library-col-result: 88px;
    --library-col-date: 8.5rem;
    --library-col-score: 84px;
    --library-col-kda: 104px;
    --library-col-rating: 66px;
    --library-col-hsadr: 66px;
    --library-col-source: 88px;
    --library-col-actions: 156px;
    --library-col-select: 22px;
    grid-template-columns:
      var(--library-col-result)
      minmax(0, 1fr)
      var(--library-col-date)
      var(--library-col-score)
      var(--library-col-kda)
      var(--library-col-rating)
      var(--library-col-hsadr)
      var(--library-col-source)
      var(--library-col-actions);
    column-gap: 10px;
  }
  .match-table-head.is-selecting,
  .library-match-row.is-selecting {
    grid-template-columns:
      var(--library-col-select)
      var(--library-col-result)
      minmax(0, 1fr)
      var(--library-col-date)
      var(--library-col-score)
      var(--library-col-kda)
      var(--library-col-rating)
      var(--library-col-hsadr)
      var(--library-col-source)
      var(--library-col-actions);
  }
  .library-match-thumb { width: 68px; height: 40px; }
  .library-score__n { font-size: 20px; }
}

/* Below 1280px: denser chrome. List rows stay a real table with horizontal
   scroll (see 768–1279 below) — do NOT relocate ADDED onto another grid row. */
@media (max-width: 1279px) {
  .match-library__top-upload { display: none; }
  .match-library__header { align-items: center; gap: 10px; margin-bottom: 10px; }
  .match-library__header h1 { font-size: 24px; }
  .match-library__header p { margin-top: 4px; font-size: 11px; }
  .match-library__header .ui-button { flex: 0 0 auto; min-height: 44px; padding-inline: 12px; }
  .match-library__actions { gap: 8px; }
  .match-metrics { grid-template-columns: 1fr 1fr; margin-bottom: 8px; }
  .match-metric {
    min-height: 50px;
    padding: 8px 10px;
    border-right: 0;
    border-bottom: 1px solid var(--color-border-soft);
  }
  .match-metric:nth-child(odd) { border-right: 1px solid var(--color-border-soft); }
  .match-metric:nth-last-child(-n + 2) { border-bottom: 0; }
  .match-metric__icon { width: 30px; height: 30px; }
  .match-metric__body > span { font-size: 9px; }
  .match-metric__body > strong { font-size: 24px; }
  .match-library__workspace { margin-inline: -4px; border-radius: var(--radius-md); }
  .match-source-tabs { padding-inline: 7px; }
  .match-source-tab { min-height: 40px; padding-inline: 9px; font-size: 12px; }
  .match-filters { grid-template-columns: 1fr 1fr; gap: 7px; padding: 9px; }
  .match-filter--search, .match-filter--sort { grid-column: 1 / -1; }
  .match-filter > span { display: none; }
  .match-filter .ui-input, .match-filter .ui-select { min-height: 42px; height: 42px; }
  .match-favorite-filter { grid-row: auto; min-height: 44px; padding-inline: 8px; }
  .match-select-toggle { grid-row: auto; min-height: 44px; height: 44px; }
  .match-view-toggle { grid-row: auto; height: 44px; justify-self: end; }
  .match-bulkbar { flex-wrap: wrap; justify-content: center; }

  .match-results--grid { grid-template-columns: 1fr; gap: 8px; padding: 9px; }
  .steam-pending--grid { grid-column: auto; }

  .upload-modal { align-items: end; padding: 0; }
  .upload-dialog { width: 100%; max-height: 92dvh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; border-bottom: 0; }
  .upload-dialog__header { padding: 15px 16px; }
  .upload-dialog form { padding: 13px 16px calc(16px + env(safe-area-inset-bottom, 0px)); }
  .upload-modes { grid-template-columns: 1fr; }
  .upload-dialog__section-head { display: grid; gap: 2px; }
  .upload-dropzone-new { min-height: 150px; padding: 16px; }
  .upload-dialog__footer .ui-button { min-height: 44px; }
}

/* Tablet / narrow desktop list: same columns as wide, horizontal scroll.
   ADDED stays in its track — never moves under MAP. */
@media (min-width: 768px) and (max-width: 1279px) {
  .match-results:not(.match-results--grid) {
    display: block;
    max-width: 100%;
    padding: 0 0 7px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-color: var(--color-border-strong) var(--color-surface);
    scrollbar-width: thin;
  }
  .match-results:not(.match-results--grid)::-webkit-scrollbar { height: 8px; }
  .match-results:not(.match-results--grid)::-webkit-scrollbar-track { background: var(--color-surface); }
  .match-results:not(.match-results--grid)::-webkit-scrollbar-thumb {
    border: 2px solid var(--color-surface);
    border-radius: var(--radius-pill);
    background: var(--color-border-strong);
  }
  .match-results:not(.match-results--grid) .match-table-head { display: grid; }
  .match-results:not(.match-results--grid) .match-table-head,
  .match-results:not(.match-results--grid) .library-match-row,
  .match-results:not(.match-results--grid) .library-match-row.is-selecting {
    --library-col-result: 90px;
    --library-col-date: 8.5rem;
    --library-col-score: 88px;
    --library-col-kda: 108px;
    --library-col-rating: 70px;
    --library-col-hsadr: 70px;
    --library-col-source: 92px;
    --library-col-actions: 162px;
    --library-col-select: 24px;
    width: 100%;
    min-width: 1100px;
    grid-template-columns:
      var(--library-col-result)
      minmax(0, 1fr)
      var(--library-col-date)
      var(--library-col-score)
      var(--library-col-kda)
      var(--library-col-rating)
      var(--library-col-hsadr)
      var(--library-col-source)
      var(--library-col-actions);
    grid-template-rows: auto;
    align-items: center;
    gap: 0 10px;
  }
  .match-results:not(.match-results--grid) .match-table-head.is-selecting,
  .match-results:not(.match-results--grid) .library-match-row.is-selecting {
    grid-template-columns:
      var(--library-col-select)
      var(--library-col-result)
      minmax(0, 1fr)
      var(--library-col-date)
      var(--library-col-score)
      var(--library-col-kda)
      var(--library-col-rating)
      var(--library-col-hsadr)
      var(--library-col-source)
      var(--library-col-actions);
  }
  .match-results:not(.match-results--grid) .match-table-head {
    min-height: 34px;
    padding: 0 14px;
  }
  .match-results:not(.match-results--grid) .library-match-row {
    min-height: 64px;
    margin: 0;
    padding: 10px 14px;
    border: 0;
    border-bottom: 1px solid var(--color-border-soft);
    border-radius: 0;
    background: var(--color-surface);
  }
  .match-results:not(.match-results--grid) .library-match-row > * {
    grid-column: auto;
    grid-row: auto;
    place-self: auto;
  }
  .match-results:not(.match-results--grid) .library-pending-meta > * {
    grid-column: auto;
    grid-row: auto;
    place-self: auto;
  }
  .match-results:not(.match-results--grid) .library-match-row__select { min-height: 0; }
  .match-results:not(.match-results--grid) .library-match-row__result {
    min-height: 0;
    place-items: start center;
  }
  .match-results:not(.match-results--grid) .library-match-row__map { min-height: 0; }
  .match-results:not(.match-results--grid) .library-match-thumb { width: 72px; height: 42px; }
  .match-results:not(.match-results--grid) .library-match-row__date {
    display: grid;
    gap: 2px;
    justify-items: start;
    white-space: normal;
  }
  .match-results:not(.match-results--grid) .library-match-row__date span { display: none; }
  .match-results:not(.match-results--grid) .library-match-row__date strong { font-size: 13px; }
  .match-results:not(.match-results--grid) .library-match-row__date small { font-size: 11px; }
  .match-results:not(.match-results--grid) .library-match-row__date small::before { content: none; }
  .match-results:not(.match-results--grid) .library-match-row__score { justify-items: center; }
  .match-results:not(.match-results--grid) .library-kda,
  .match-results:not(.match-results--grid) .library-rating,
  .match-results:not(.match-results--grid) .library-hsadr {
    justify-items: center;
    text-align: center;
  }
  .match-results:not(.match-results--grid) .library-match-row__source {
    display: grid;
    gap: 4px;
    justify-items: start;
  }
  .match-results:not(.match-results--grid) .library-match-row__source .source-item > span:last-child { display: block; }
  .match-results:not(.match-results--grid) .library-match-row__actions {
    grid-template-columns: minmax(0, 1fr) 34px 34px;
  }
  .match-results:not(.match-results--grid) .library-match-row__actions > .ui-button,
  .match-results:not(.match-results--grid) .library-pending-import > .ui-button {
    min-height: 34px;
    height: 34px;
  }
  .match-results:not(.match-results--grid) .library-2d-button { width: 34px; height: 34px; }
  .match-results:not(.match-results--grid) .library-more-button { min-height: 34px !important; height: 34px !important; }
  .match-results:not(.match-results--grid) .library-series-maps,
  .match-results:not(.match-results--grid) .library-match-row.is-selecting > .library-series-maps {
    grid-column: 2 / -1;
    grid-row: auto;
  }
  .match-results--grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .library-grid-card__visual { height: 104px; }
}

/* Phone cards only (<768). ADDED may sit under the map here by design. */
@media (max-width: 767px) {
  .match-table-head { display: none; }
  .library-match-row__date > span { display: inline; }

  .match-results:not(.match-results--grid) {
    display: grid;
    gap: 8px;
    padding: 8px;
  }
  .library-match-row,
  .library-match-row.is-selecting {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    align-items: center;
    gap: 8px 6px;
    min-height: 0;
    margin: 0;
    padding: 10px;
    border: 1px solid var(--color-border-soft);
    border-radius: var(--radius-md);
    background: var(--color-bg-elevated);
  }
  .library-match-row:last-of-type { border-bottom-color: var(--color-border-soft); }
  .library-match-row__select {
    grid-column: 1;
    grid-row: 1;
    min-height: 28px;
  }
  .library-match-row__result,
  .library-match-row.is-selecting > .library-match-row__result {
    grid-column: 1 / 4;
    grid-row: 1;
    min-height: 28px;
    place-items: center start;
  }
  .library-match-row.is-selecting > .library-match-row__result { grid-column: 2 / 4; }
  .library-match-row__score,
  .library-match-row.is-selecting > .library-match-row__score {
    grid-column: 4 / 7;
    grid-row: 1;
    justify-items: end;
  }
  .library-match-row__map,
  .library-match-row.is-selecting > .library-match-row__map {
    grid-column: 1 / 7;
    grid-row: 2;
    min-height: 46px;
  }
  .library-match-row.is-selecting > .library-match-row__map { grid-column: 2 / 7; }
  .library-match-thumb { width: 72px; height: 44px; }
  .library-match-row__date,
  .library-match-row.is-selecting > .library-match-row__date {
    grid-column: 1 / 7;
    grid-row: 3;
    min-width: 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
  }
  .library-match-row.is-selecting > .library-match-row__date { grid-column: 2 / 7; }
  .library-match-row__date span { display: inline; }
  .library-match-row__date strong { font-size: 11px; }
  .library-match-row__date small::before { content: "· "; }
  .library-match-row > .library-kda,
  .library-match-row.is-selecting > .library-kda {
    grid-column: 1 / 3;
    grid-row: 4;
    justify-self: start;
  }
  .library-match-row > .library-rating,
  .library-match-row.is-selecting > .library-rating {
    grid-column: 3 / 5;
    grid-row: 4;
    justify-self: center;
  }
  .library-match-row > .library-hsadr,
  .library-match-row.is-selecting > .library-hsadr {
    grid-column: 5 / 7;
    grid-row: 4;
    justify-self: end;
  }
  .library-match-row.is-selecting > .library-kda { grid-column: 2 / 4; }
  .library-match-row.is-selecting > .library-rating { grid-column: 4 / 5; }
  .library-match-row.is-selecting > .library-hsadr { grid-column: 5 / 7; }
  .library-kda, .library-rating, .library-hsadr {
    display: grid;
    justify-items: start;
    text-align: left;
  }
  .library-match-row__source,
  .library-match-row.is-selecting > .library-match-row__source {
    grid-column: 1 / 7;
    grid-row: 5;
  }
  .library-match-row.is-selecting > .library-match-row__source { grid-column: 2 / 7; }
  .library-match-row__actions,
  .library-match-row.is-selecting > .library-match-row__actions {
    grid-column: 1 / 7;
    grid-row: 6;
    grid-template-columns: minmax(0, 1fr) 44px 44px;
    justify-content: stretch;
  }
  .library-match-row.is-selecting > .library-match-row__actions { grid-column: 2 / 7; }
  .library-match-row__actions > .ui-button { width: 100%; min-height: 44px; height: 44px; }
  .library-main-action { width: 100%; }
  .library-pending-import { width: 100%; }
  .library-pending-import > .ui-button { width: 100%; min-height: 44px; height: 44px; }
  .library-2d-button { width: 44px; height: 44px; }
  .library-more-button { min-height: 44px !important; height: 44px !important; }
  .library-action-menu__panel {
    position: fixed;
    right: 12px;
    bottom: calc(var(--bottomnav-height) + 14px);
    top: auto;
    width: min(260px, calc(100vw - 24px));
  }
  .library-action-menu__panel button { min-height: 44px; }
  .library-series-maps,
  .library-match-row.is-selecting > .library-series-maps {
    grid-column: 1 / 7;
    grid-row: 7;
  }
  .library-match-row.is-selecting > .library-series-maps { grid-column: 2 / 7; }
  .match-results--grid {
    grid-template-columns: minmax(0, 620px);
    justify-content: center;
  }
  .library-grid-card { width: 100%; }
  .library-grid-card__visual { height: clamp(92px, 28vw, 112px); }
  .library-grid-card__topline { flex-wrap: wrap; }
  .library-score__n { font-size: 16px; }
}

@media (min-width: 900px) and (max-width: 959px) {
  .match-results--grid {
    grid-template-columns: minmax(0, 620px);
    justify-content: center;
  }
}

@media (max-width: 600px) {
  .match-library__header { align-items: stretch; flex-direction: column; }
  .match-library__actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .match-library__actions .ui-button { min-width: 0; width: 100%; padding-inline: 8px; }
  .match-bulkbar {
    bottom: calc(var(--bottomnav-height) + env(safe-area-inset-bottom, 0px) + 12px);
    max-width: calc(100vw - 20px);
  }
  .match-view-toggle { grid-column: 1 / -1; justify-self: center; }
  .library-match-row__date { gap: 3px; }
  .library-match-row__date strong,
  .library-match-row__date small { font-size: 10px; }
  .library-kda__vals b { font-size: 17px; }
  .library-rating > strong { min-width: 50px; font-size: 16px; }
  .library-hsadr b { font-size: 15px; }
}

@media (max-width: 374px) {
  .match-library__header { flex-direction: column; }
  .match-library__actions { width: 100%; }
  .match-library__actions .ui-button { flex: 1 1 auto; }
  .match-filters { grid-template-columns: 1fr; }
  .match-filter--search, .match-filter--sort { grid-column: auto; }
  .match-view-toggle { justify-self: stretch; }
  .match-view-toggle label { flex: 1; }
  .library-match-thumb { width: 68px; }
  .library-match-row__actions { grid-template-columns: minmax(0, 1fr) 42px 42px; }
}
