/* Médiathèque desktop : tokens ABO, sélection stable, défilements indépendants. */
.media-shell {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 32px;
  gap: 24px;
  background: var(--canvas);
}
.media-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  flex: none;
}
.media-head h1 {
  font-size: 28px;
  font-weight: 550;
  line-height: 1.3;
  letter-spacing: -0.025em;
  margin: 0 0 8px;
}
.media-head p {
  color: var(--ink-2);
  max-width: 66ch;
  font-size: 13px;
  line-height: 1.65;
}
.media-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.media-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink-2);
  min-height: 40px;
  font-weight: 500;
  white-space: normal;
  text-align: center;
}
.media-button.primary {
  background: var(--v);
  color: var(--paper);
}
.media-button.danger {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 9%, var(--paper));
}
.media-button:hover {
  filter: brightness(0.97);
}
.media-filters {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  flex: none;
}
.media-filters input[type="search"] {
  flex: 1;
  min-width: 180px;
}
.media-filters select {
  max-width: 240px;
}
.media-filters .media-validation {
  flex: none;
  white-space: nowrap;
  align-items: center;
}
.media-filters input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--v);
  margin: 0;
}
.port[data-page="images"]::before {
  content: none;
}
.media-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  font-size: 12px;
  color: var(--ink-2);
}
.media-field input,
.media-field select,
.media-field textarea,
.media-filters input,
.media-filters select {
  padding: 10px 12px;
  background: var(--paper);
  border: 1px solid var(--line-2);
  border-radius: 7px;
  font-size: 13px;
  color: var(--ink);
  width: 100%;
  min-width: 0;
  line-height: 1.5;
}
.media-field textarea {
  resize: vertical;
  min-height: 80px;
}
.media-field small {
  font-size: 11px;
  line-height: 1.5;
  color: var(--ink-3);
}
.media-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  min-height: 0;
  flex: 1;
}
.media-layout.has-selection {
  grid-template-columns: minmax(0, 1fr) 340px;
}
.media-grid {
  overflow-y: auto;
  scrollbar-gutter: stable;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 18px;
  align-content: start;
  min-height: 0;
  padding: 2px 4px 24px 2px;
}
.media-card {
  display: flex;
  flex-direction: column;
  text-align: left;
  gap: 10px;
  background: var(--paper);
  border-radius: 9px;
  padding: 10px;
  min-width: 0;
  outline-offset: 2px;
}
.media-card[aria-pressed="true"] {
  outline: 2px solid var(--v);
}
.media-card img {
  width: 100%;
  height: 150px;
  object-fit: contain;
  background: var(--nav);
  border-radius: 5px;
}
.media-card .media-title {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.media-card small {
  font-size: 11px;
  line-height: 1.5;
  color: var(--ink-3);
}
.media-inspector {
  overflow-y: auto;
  scrollbar-gutter: stable;
  min-height: 0;
  padding: 0 12px 24px 4px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}
.media-inspector img {
  width: 100%;
  max-height: 240px;
  object-fit: contain;
  background: var(--paper);
  border-radius: 8px;
}
.media-inspector h2 {
  font-size: 18px;
  font-weight: 550;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.media-inspector p,
.media-inspector dd {
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.media-inspector dt {
  font-size: 11px;
  color: var(--ink-3);
  margin: 14px 0 4px;
}
.media-inspector details {
  font-size: 12px;
  color: var(--ink-2);
}
.media-inspector summary {
  cursor: pointer;
  padding: 6px 0;
}
.media-empty {
  grid-column: 1/-1;
  padding: 48px 24px;
  text-align: center;
  color: var(--ink-2);
  line-height: 1.8;
}
.media-count {
  font-size: 12px;
  color: var(--ink-3);
  white-space: nowrap;
}
.media-shell .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.media-dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(940px, calc(100vw - 80px));
  max-height: calc(100vh - 80px);
  border: 0;
  border-radius: 14px;
  padding: 0;
  background: var(--canvas);
  color: var(--ink);
  box-shadow: var(--shadow-modal);
  font-family: var(--sans);
}
.media-dialog::backdrop {
  background: rgba(28, 37, 43, 0.45);
}
.media-dialog form {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 80px);
}
.media-dialog header {
  padding: 24px 28px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  flex: none;
  background: var(--paper);
}
.media-dialog h2 {
  font-size: 22px;
  font-weight: 550;
  line-height: 1.4;
}
.media-dialog header p {
  margin-top: 6px;
  color: var(--ink-2);
  font-size: 12px;
  max-width: 70ch;
}
.media-form-body {
  overflow: auto;
  min-height: 0;
  padding: 24px 28px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px 24px;
}
.media-form-body .wide {
  grid-column: 1/-1;
}
.media-upload-preview {
  max-height: 140px;
  width: 100%;
  object-fit: contain;
}
.media-dialog footer {
  padding: 18px 28px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  flex: none;
  background: var(--paper);
}
.media-error {
  font-size: 12px;
  color: var(--danger);
  margin-right: auto;
  white-space: pre-wrap;
  max-width: 60ch;
}
.media-validation {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 12px;
  line-height: 1.6;
  color: var(--ink-2);
}
.media-validation input {
  margin-top: 4px;
  flex: none;
}
.media-category-row {
  display: flex;
  align-items: center;
  gap: 12px;
  grid-column: 1/-1;
}
.media-category-row input {
  flex: 1;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line-2);
  border-radius: 7px;
  background: var(--paper);
}
@media (max-width: 1250px) {
  .media-shell {
    padding: 24px;
    gap: 20px;
  }
  .media-layout,
  .media-layout.has-selection {
    grid-template-columns: minmax(0, 1fr) 290px;
    gap: 18px;
  }
  .media-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
  .media-head {
    flex-wrap: wrap;
  }
}
