.attachment-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  gap: 14px;
  min-width: 0;
}

article.ruess-attachment.attachment-card {
  display: grid;
  grid-template-rows: 150px minmax(0, 1fr);
  min-width: 0;
  overflow: hidden;
  border: 1px solid #dfe4df;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 5px 16px rgba(35, 47, 40, .06);
}

article.ruess-attachment.attachment-card-file { grid-column: auto; }

article.ruess-attachment button.attachment-control {
  box-shadow: none;
  transform: none;
}

article.ruess-attachment button.attachment-thumbnail {
  display: grid;
  width: 100%;
  height: 150px;
  margin: 0;
  padding: 0;
  place-items: center;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: #f1f3f1;
  color: #4d5e51;
  cursor: pointer;
}

article.ruess-attachment button.attachment-thumbnail:hover {
  background: #e9ede9;
  color: #3d4c41;
  transform: none;
}

article.ruess-attachment button.attachment-thumbnail:disabled,
article.ruess-attachment button.attachment-title:disabled {
  cursor: default;
  opacity: 1;
}

article.ruess-attachment button.attachment-thumbnail:disabled:hover { background: #f1f3f1; }

article.ruess-attachment .attachment-thumbnail img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #f1f3f1;
}

article.ruess-attachment .attachment-image-placeholder {
  display: grid;
  width: 100%;
  height: 100%;
  padding: 16px;
  place-items: center;
  color: #627066;
  background: #f1f3f1;
  font-size: 12px;
  text-align: center;
}

article.ruess-attachment .attachment-thumbnail-error { color: #983a33; background: #fff1ef; }

article.ruess-attachment .attachment-file-icon {
  display: grid;
  width: 78px;
  height: 92px;
  place-items: center;
  border-radius: 9px;
  background: #fff;
  color: #526159;
  box-shadow: 0 6px 16px rgba(30, 44, 35, .12);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .05em;
}

article.ruess-attachment .attachment-file-icon-pdf { border-top: 8px solid #bf332b; background: #fff2f0; color: #a72b24; }
article.ruess-attachment .attachment-file-icon-video { border-top: 8px solid #46677d; background: #eef2f5; color: #334b5b; }
article.ruess-attachment .attachment-file-icon-file { border-top: 8px solid #5c82aa; background: #edf3fb; color: #315c8a; }
article.ruess-attachment .attachment-file-icon-browser { border-top: 8px solid #79867d; background: #f4f6f4; color: #4c5a50; }

article.ruess-attachment .attachment-card-body {
  display: flex;
  min-width: 0;
  overflow: hidden;
  flex-direction: column;
  gap: 5px;
  padding: 13px;
  background: #fff;
}

article.ruess-attachment button.attachment-title {
  display: -webkit-box;
  width: auto;
  max-width: 100%;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #253329;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.25;
  text-align: left;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

article.ruess-attachment button.attachment-title:not(:disabled):hover {
  background: transparent;
  color: #1d2821;
  text-decoration: underline;
  transform: none;
}

article.ruess-attachment .attachment-name {
  overflow: hidden;
  color: #566159;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

article.ruess-attachment .attachment-meta { color: #747e77; font-size: 11px; }

article.ruess-attachment .attachment-actions {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: auto;
  padding-top: 8px;
}

article.ruess-attachment .attachment-actions button {
  width: auto;
  min-width: 0;
  max-width: 100%;
  min-height: 38px;
  margin: 0;
  padding: 8px 11px;
  white-space: normal;
  overflow-wrap: anywhere;
}

article.ruess-attachment .attachment-actions button.secondary {
  border: 1px solid #cdd4ce;
  background: #f7f8f7;
  color: #354139;
}

article.ruess-attachment .attachment-actions button.secondary:hover { background: #ecefec; color: #27322b; }
article.ruess-attachment .attachment-actions button.danger { background: #ad2f34; color: #fff; }
article.ruess-attachment .attachment-actions button.danger:hover { background: #92272b; color: #fff; }

.ruess-attachment-preview.attachment-preview-modal {
  z-index: 13000;
  padding: 14px;
  background: rgba(8, 12, 9, .88);
}

.ruess-attachment-preview .attachment-preview-dialog {
  display: grid;
  width: min(1500px, calc(100vw - 28px));
  height: min(960px, calc(100dvh - 28px));
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border-radius: 18px;
  background: #f5f7f4;
  box-shadow: 0 22px 70px rgba(0, 0, 0, .38);
}

.ruess-attachment-preview .attachment-preview-dialog > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border-bottom: 1px solid #dbe2da;
  background: #fff;
}

.ruess-attachment-preview .attachment-preview-dialog h2 {
  max-width: min(70vw, 900px);
  margin: 2px 0 0;
  overflow: hidden;
  color: #233127;
  font-size: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ruess-attachment-preview .attachment-preview-dialog header span { color: #748077; font-size: 11px; font-weight: 800; letter-spacing: .08em; }
.ruess-attachment-preview .attachment-preview-header-actions { display: flex; align-items: center; gap: 8px; }
.ruess-attachment-preview .attachment-preview-header-actions button { width: auto; margin: 0; }

.ruess-attachment-preview button.attachment-preview-close {
  display: grid;
  width: 44px;
  height: 44px;
  padding: 0;
  place-items: center;
  border-radius: 999px;
  background: #26372c;
  color: #fff;
  font-size: 27px;
}

.ruess-attachment-preview button.attachment-preview-close:hover { background: #1c2921; color: #fff; }

.ruess-attachment-preview .attachment-preview-content {
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
  overflow: auto;
  background: #262b27;
}

.ruess-attachment-preview .attachment-preview-content img,
.ruess-attachment-preview .attachment-preview-content video { display: block; max-width: 100%; max-height: 100%; object-fit: contain; }
.ruess-attachment-preview .attachment-preview-content iframe { display: block; width: 100%; height: 100%; min-height: 0; border: 0; background: #fff; }
.ruess-attachment-preview .attachment-preview-loading,
.ruess-attachment-preview .attachment-preview-error { padding: 28px; color: #fff; text-align: center; }
.ruess-attachment-preview .attachment-preview-error strong { font-size: 20px; }
.ruess-attachment-preview .attachment-preview-error p { color: #e8ece8; }

@media (max-width: 600px) {
  .attachment-gallery { grid-template-columns: 1fr; }
  article.ruess-attachment.attachment-card { grid-template-columns: 104px minmax(0, 1fr); grid-template-rows: minmax(132px, auto); }
  article.ruess-attachment button.attachment-thumbnail { height: 100%; min-height: 132px; }
  article.ruess-attachment .attachment-card-body { padding: 11px; }
  article.ruess-attachment .attachment-actions button { min-height: 42px; }
  .ruess-attachment-preview.attachment-preview-modal { padding: 0; }
  .ruess-attachment-preview .attachment-preview-dialog { width: 100vw; height: 100dvh; border-radius: 0; }
  .ruess-attachment-preview .attachment-preview-dialog > header { align-items: flex-start; padding: 9px; }
  .ruess-attachment-preview .attachment-preview-dialog h2 { max-width: 58vw; font-size: 15px; }
  .ruess-attachment-preview .attachment-preview-header-actions .secondary { padding: 9px; font-size: 12px; }
  .ruess-attachment-preview button.attachment-preview-close { width: 42px; height: 42px; }
  .ruess-attachment-preview .attachment-preview-content iframe { min-height: calc(100dvh - 68px); }
}

@media (max-width: 430px) {
  article.ruess-attachment.attachment-card { grid-template-columns: 1fr; grid-template-rows: 120px auto; }
  article.ruess-attachment button.attachment-thumbnail { min-height: 120px; }
  article.ruess-attachment .attachment-actions { gap: 5px; }
  article.ruess-attachment .attachment-actions button { padding: 7px 8px; font-size: 11px; }
  .ruess-attachment-preview .attachment-preview-header-actions { gap: 5px; }
}

/* 2.25.4: Browser-unabhaengige PDF-Vorschau via PDF.js statt eingebettetem PDF-Plugin. */
.ruess-attachment-preview .attachment-pdf-viewer {
  display: grid;
  width: 100%;
  min-width: 0;
  min-height: 100%;
  grid-template-rows: auto minmax(0, 1fr);
  align-self: stretch;
  background: #262b27;
}

.ruess-attachment-preview .attachment-pdf-toolbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 7px 12px;
  border-bottom: 1px solid #dbe2da;
  background: #fff;
  color: #354139;
}

.ruess-attachment-preview .attachment-pdf-navigation,
.ruess-attachment-preview .attachment-pdf-zoom { display: flex; align-items: center; gap: 8px; }
.ruess-attachment-preview .attachment-pdf-pages { min-width: 58px; font-size: 12px; font-weight: 800; text-align: center; }
.ruess-attachment-preview .attachment-pdf-zoom span { min-width: 48px; color: #526159; font-size: 12px; font-weight: 800; text-align: center; }
.ruess-attachment-preview .attachment-pdf-navigation button,
.ruess-attachment-preview .attachment-pdf-zoom button { width: 38px; min-width: 38px; height: 34px; min-height: 34px; margin: 0; padding: 0; }

.ruess-attachment-preview .attachment-pdf-pages-container {
  display: flex;
  width: 100%;
  min-width: 0;
  min-height: 0;
  align-items: flex-start;
  justify-content: center;
  overflow: auto;
  padding: 16px 14px 26px;
}

.ruess-attachment-preview .attachment-pdf-page {
  display: block;
  max-width: 100%;
  flex: 0 0 auto;
  overflow: auto;
  background: #fff;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .28);
}

.ruess-attachment-preview .attachment-pdf-page canvas { display: block; max-width: none; background: #fff; }

@media (max-width: 600px) {
  .ruess-attachment-preview .attachment-pdf-toolbar { min-height: 44px; padding: 5px 8px; }
  .ruess-attachment-preview .attachment-pdf-pages-container { gap: 12px; padding: 10px 8px 18px; }
  .ruess-attachment-preview .attachment-pdf-navigation,
  .ruess-attachment-preview .attachment-pdf-zoom { gap: 5px; }
  .ruess-attachment-preview .attachment-pdf-navigation button,
  .ruess-attachment-preview .attachment-pdf-zoom button { width: 36px; min-width: 36px; height: 34px; min-height: 34px; }
}
