:root {
  --md-sys-color-background: #fffbff;
  --md-sys-color-surface: #fffbff;
  --md-sys-color-surface-container: #f3edf7;
  --md-sys-color-surface-container-low: #f7f2fa;
  --md-sys-color-surface-container-high: #ece6f0;
  --md-sys-color-on-surface: #1d1b20;
  --md-sys-color-on-surface-variant: #49454f;
  --md-sys-color-outline: #79747e;
  --md-sys-color-outline-variant: #cac4d0;
  --md-sys-color-primary: #006a6a;
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-primary-container: #6ff7f6;
  --md-sys-color-on-primary-container: #002020;
  --md-sys-color-secondary: #625b71;
  --md-sys-color-error: #ba1a1a;
  --md-sys-color-error-container: #ffdad6;
  --md-elevation-1: 0 1px 2px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.08);
  --md-elevation-2: 0 2px 6px rgba(0, 0, 0, 0.13), 0 1px 2px rgba(0, 0, 0, 0.08);
  --md-elevation-3: 0 6px 14px rgba(0, 0, 0, 0.14), 0 2px 4px rgba(0, 0, 0, 0.08);
  --focus-ring: 0 0 0 3px rgba(0, 106, 106, 0.22);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--md-sys-color-background);
  color: var(--md-sys-color-on-surface);
  font-family:
    ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei",
    sans-serif;
}

button,
input {
  font: inherit;
}

button,
a,
input {
  -webkit-tap-highlight-color: transparent;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.admin-shell {
  width: min(1320px, calc(100vw - 24px));
  padding: 8px 0 16px;
}

.topbar,
.gallery-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.gallery-hero {
  align-items: center;
  min-height: 180px;
  padding: 28px;
  border-radius: 8px;
  background: var(--md-sys-color-surface-container-low);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--md-sys-color-primary);
  font-size: 13px;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.08;
  letter-spacing: 0;
}

.hero-copy {
  max-width: 520px;
  margin: 12px 0 0;
  color: var(--md-sys-color-on-surface-variant);
  line-height: 1.6;
}

.top-actions,
.stats,
.tool-row,
.auth-actions,
.upload-actions,
.preview-actions,
.lightbox-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.top-actions {
  justify-content: flex-end;
}

.admin-topbar {
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.admin-topbar .title-block {
  flex: 0 0 auto;
}

.admin-topbar .eyebrow {
  display: none;
}

.admin-topbar h1 {
  font-size: clamp(22px, 2.4vw, 30px);
}

.topbar-controls {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.admin-topbar .top-actions {
  gap: 5px;
}

.admin-shell .action,
.admin-shell .icon-button {
  min-height: 30px;
  border-radius: 6px;
}

.admin-shell .action {
  padding: 4px 9px;
  font-size: 12px;
}

.admin-shell .icon-button {
  width: 30px;
  font-size: 17px;
}

.admin-shell .stats {
  gap: 6px;
}

.admin-shell .stats span {
  min-width: 56px;
  padding: 4px 8px;
  font-size: 12px;
}

.auth-actions {
  justify-content: flex-end;
}

.stats span {
  min-width: 72px;
  padding: 8px 12px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 8px;
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface-variant);
  text-align: center;
  font-size: 13px;
  box-shadow: var(--md-elevation-1);
}

.gallery-stats {
  justify-content: flex-end;
}

.action,
.icon-button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid var(--md-sys-color-outline);
  background: transparent;
  color: var(--md-sys-color-primary);
  cursor: pointer;
  text-decoration: none;
  transition:
    background-color 140ms ease,
    border-color 140ms ease,
    box-shadow 140ms ease;
}

.action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  font-weight: 650;
}

.icon-button {
  width: 40px;
  display: grid;
  place-items: center;
  font-size: 20px;
}

.action:hover,
.icon-button:hover {
  background: rgba(0, 106, 106, 0.08);
}

.action:focus-visible,
.icon-button:focus-visible,
input:focus-visible,
.crumb:focus-visible,
.gallery-card:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.action:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.action.primary {
  border-color: var(--md-sys-color-primary);
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  box-shadow: var(--md-elevation-1);
}

.action.primary:hover {
  background: #005b5b;
}

.action.danger {
  border-color: var(--md-sys-color-error-container);
  color: var(--md-sys-color-error);
}

.admin-panel,
.list-panel,
.preview {
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 8px;
  background: var(--md-sys-color-surface);
  box-shadow: var(--md-elevation-1);
  overflow: hidden;
}

.admin-panel {
  padding: 16px;
  margin-bottom: 16px;
}

.admin-login,
.upload-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.header-auth,
.session-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.header-auth[hidden],
.session-controls[hidden] {
  display: none;
}

.auth-identity {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(160px, 230px);
  align-items: center;
  gap: 5px;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 12px;
  font-weight: 700;
}

.auth-identity input {
  width: 100%;
  min-height: 30px;
  border: 1px solid var(--md-sys-color-outline);
  border-radius: 6px;
  padding: 4px 8px;
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
}

.session-controls {
  max-width: 100%;
  padding: 3px 4px 3px 8px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 7px;
  background: var(--md-sys-color-surface-container-low);
}

.session-controls strong {
  min-width: 0;
  max-width: min(360px, 42vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.manager-tools {
  display: grid;
  gap: 6px;
}

.table-tools {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 6px;
  padding: 5px 8px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  background: color-mix(in srgb, var(--md-sys-color-surface-container-low) 66%, white);
}

.session-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 8px;
  background: var(--md-sys-color-surface-container-low);
}

.session-row strong {
  display: block;
  margin-top: 3px;
  overflow-wrap: anywhere;
}

.session-label {
  color: var(--md-sys-color-on-surface-variant);
  font-size: 12px;
  font-weight: 700;
}

.selection-tools {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 6px 8px;
  align-items: center;
}

.selection-actions {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.selection-count {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--md-sys-color-surface-container-low);
  color: var(--md-sys-color-on-surface-variant);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.upload-form {
  grid-template-columns: minmax(180px, 280px) minmax(220px, 1fr) auto;
}

.compact-upload {
  grid-template-columns: auto minmax(150px, 210px) minmax(180px, 1fr) auto;
  gap: 6px;
  align-items: end;
}

.upload-details {
  min-width: max-content;
}

.upload-details > summary {
  list-style: none;
}

.upload-details > summary::-webkit-details-marker {
  display: none;
}

.upload-details[open] {
  grid-column: 1 / -1;
  min-width: 0;
}

.upload-details[open] > summary {
  width: max-content;
  margin: 0 0 6px auto;
}

.upload-drawer {
  display: grid;
  gap: 6px;
  padding: 7px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 8px;
  background: var(--md-sys-color-surface);
}

.admin-login label,
.upload-form label,
.search {
  display: grid;
  gap: 4px;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 13px;
  font-weight: 650;
}

.file-picker {
  min-width: 0;
}

.admin-login input,
.upload-form input[type="text"],
.upload-form input[type="password"],
.upload-form input[type="file"],
.search input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--md-sys-color-outline);
  border-radius: 8px;
  padding: 8px 12px;
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
}

.admin-shell .upload-form input[type="text"],
.admin-shell .upload-form input[type="password"],
.admin-shell .upload-form input[type="file"],
.admin-shell .search input {
  min-height: 30px;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
}

.upload-form input[type="file"] {
  min-width: 0;
  overflow: hidden;
}

.upload-form input[type="file"]::file-selector-button {
  min-height: 28px;
  margin-right: 10px;
  border: 0;
  border-radius: 6px;
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-primary);
  font-weight: 700;
}

.search input::placeholder {
  color: color-mix(in srgb, var(--md-sys-color-on-surface-variant) 70%, transparent);
}

.check {
  display: inline-flex !important;
  align-items: center;
  gap: 8px !important;
  white-space: nowrap;
}

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 34px;
  border: 1px dashed var(--md-sys-color-outline);
  border-radius: 8px;
  color: var(--md-sys-color-on-surface-variant);
  background: var(--md-sys-color-surface-container-low);
  font-size: 12px;
}

.drop-zone.dragging {
  border-color: var(--md-sys-color-primary);
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}

.admin-status {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--md-sys-color-on-surface-variant);
}

.header-status {
  max-width: min(720px, 100%);
  min-height: 0;
  margin: 0;
  font-size: 12px;
  text-align: right;
}

.toolbar,
.gallery-toolbar {
  display: grid;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
}

.toolbar {
  grid-template-columns: 1fr minmax(220px, 320px);
}

.gallery-toolbar {
  grid-template-columns: minmax(220px, 360px);
  justify-content: end;
}

.breadcrumbs {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.table-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 260px);
  gap: 8px;
  align-items: center;
  padding: 5px 8px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface);
}

.table-toolbar .breadcrumbs {
  min-height: 30px;
}

.table-toolbar .search {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 6px;
}

.table-toolbar .crumb {
  padding: 4px 7px;
  border-radius: 6px;
  font-size: 12px;
}

.crumb {
  border: 0;
  background: transparent;
  color: var(--md-sys-color-primary);
  cursor: pointer;
  padding: 8px 10px;
  border-radius: 8px;
  font-weight: 650;
}

.crumb:hover {
  background: rgba(0, 106, 106, 0.08);
}

.separator {
  color: var(--md-sys-color-on-surface-variant);
}

.content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 8px;
  align-items: start;
}

.list-head,
.file-row {
  display: grid;
  grid-template-columns: 24px minmax(180px, 1fr) 78px 118px;
  gap: 7px;
  align-items: center;
}

.shell:not(.admin-shell) .list-head,
.shell:not(.admin-shell) .file-row {
  grid-template-columns: minmax(180px, 1fr) 78px 118px;
}

.list-head {
  padding: 4px 8px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-on-surface-variant);
  font-size: 12px;
  font-weight: 700;
}

.select-heading {
  text-align: center;
  font-size: 11px;
}

.file-list {
  min-height: 220px;
}

.file-row {
  width: 100%;
  min-height: 34px;
  padding: 3px 8px;
  border: 0;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.file-row:last-child {
  border-bottom: 0;
}

.file-row:hover,
.file-row:focus-visible,
.file-row.active,
.file-row.selected {
  background: var(--md-sys-color-surface-container-low);
  outline: none;
}

.file-row.selected.active {
  background: var(--md-sys-color-primary-container);
}

.select-cell {
  display: grid;
  place-items: center;
  align-self: stretch;
}

.bulk-check {
  width: 15px;
  height: 15px;
  accent-color: var(--md-sys-color-primary);
  cursor: pointer;
}

.name-cell {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
}

.file-icon {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-secondary);
  font-weight: 800;
  font-size: 10px;
}

.folder .file-icon {
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}

.file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 650;
}

.meta,
.muted,
.empty,
.loading {
  color: var(--md-sys-color-on-surface-variant);
}

.meta {
  font-size: 11px;
}

.preview {
  position: sticky;
  top: 12px;
}

.preview-box {
  min-height: 320px;
  padding: 10px;
}

.preview-title {
  margin: 0 0 14px;
  font-size: 18px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.preview-actions {
  margin-bottom: 14px;
}

.preview-media {
  width: 100%;
  max-height: 520px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 8px;
  background: var(--md-sys-color-surface-container-low);
}

img.preview-media {
  height: auto;
  object-fit: contain;
}

pre.preview-text {
  max-height: 520px;
  overflow: auto;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 8px;
  background: #1d1b20;
  color: #f7f2fa;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  align-items: stretch;
}

.gallery-card {
  min-width: 0;
  padding: 0;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 8px;
  overflow: hidden;
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
  text-align: left;
  box-shadow: var(--md-elevation-1);
  transition:
    box-shadow 140ms ease,
    transform 140ms ease,
    border-color 140ms ease;
}

.gallery-card:hover {
  border-color: var(--md-sys-color-primary);
  box-shadow: var(--md-elevation-2);
  transform: translateY(-1px);
}

.gallery-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--md-sys-color-surface-container);
}

.gallery-card span {
  display: block;
  min-height: 44px;
  padding: 12px;
  overflow: hidden;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 14px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty {
  display: grid;
  gap: 6px;
  justify-items: center;
  padding: 52px 16px;
  text-align: center;
}

.error {
  color: var(--md-sys-color-error);
}

.lightbox {
  width: min(1040px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  box-shadow: var(--md-elevation-3);
}

.lightbox::backdrop {
  background: rgba(29, 27, 32, 0.6);
}

.lightbox-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.lightbox-head strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lightbox img {
  display: block;
  width: 100%;
  max-height: calc(100vh - 180px);
  object-fit: contain;
  background: var(--md-sys-color-surface-container-low);
}

.lightbox-actions {
  justify-content: center;
  padding: 14px 16px 16px;
}

@media (max-width: 900px) {
  .topbar,
  .gallery-hero,
  .toolbar,
  .admin-login,
  .upload-form {
    grid-template-columns: 1fr;
  }

  .topbar,
  .gallery-hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-topbar {
    gap: 10px;
    margin-bottom: 10px;
  }

  .topbar-controls,
  .header-status {
    width: 100%;
    justify-items: stretch;
    text-align: left;
  }

  .header-auth,
  .session-controls {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .auth-identity {
    flex: 1 1 260px;
  }

  .top-actions,
  .stats,
  .auth-actions,
  .gallery-stats {
    justify-content: flex-start;
  }

  .session-row {
    align-items: stretch;
    flex-direction: column;
  }

  .session-row .action {
    align-self: flex-start;
  }

  .selection-tools {
    grid-template-columns: 1fr;
  }

  .selection-actions .action {
    flex: 1 1 116px;
  }

  .table-tools {
    grid-template-columns: 1fr;
  }

  .upload-details {
    min-width: 0;
  }

  .upload-details > summary {
    width: max-content;
  }

  .table-toolbar {
    grid-template-columns: 1fr;
  }

  .compact-upload {
    grid-template-columns: 1fr 1fr;
  }

  .content {
    grid-template-columns: 1fr;
  }

  .preview {
    position: static;
  }

  .gallery-toolbar {
    justify-content: stretch;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100vw - 20px, 1180px);
    padding: 18px 0;
  }

  .admin-shell {
    width: min(100vw - 16px, 1320px);
    padding: 10px 0 14px;
  }

  .admin-topbar h1 {
    font-size: 24px;
  }

  .eyebrow {
    margin-bottom: 3px;
    font-size: 12px;
  }

  .gallery-hero {
    min-height: 0;
    padding: 20px;
  }

  .topbar-controls {
    gap: 6px;
  }

  .top-actions {
    width: 100%;
    gap: 5px;
  }

  .stats {
    width: auto;
    gap: 5px;
  }

  .stats span {
    flex: 0 0 auto;
  }

  .admin-shell .action {
    padding: 5px 8px;
  }

  .auth-identity {
    grid-template-columns: 1fr;
    flex-basis: 100%;
  }

  .auth-actions,
  .upload-actions {
    width: 100%;
    gap: 6px;
  }

  .auth-actions .action,
  .upload-actions .action {
    flex: 1 1 0;
  }

  .session-controls {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 6px;
  }

  .session-controls strong {
    max-width: none;
  }

  .table-toolbar,
  .table-tools {
    padding: 7px;
  }

  .selection-actions {
    gap: 6px;
  }

  .selection-actions .action {
    flex: 1 1 72px;
    font-size: 11px;
  }

  .upload-details > summary {
    width: 100%;
  }

  .compact-upload {
    grid-template-columns: 1fr;
  }

  .drop-zone {
    min-height: 38px;
  }

  .list-head {
    display: none;
  }

  .file-row {
    grid-template-columns: 24px minmax(0, 1fr) 54px;
    gap: 6px;
    min-height: 38px;
    padding: 4px 8px;
  }

  .shell:not(.admin-shell) .file-row {
    grid-template-columns: minmax(0, 1fr) 54px;
  }

  .file-row .meta {
    grid-column: auto;
    line-height: 1.15;
    text-align: right;
    white-space: nowrap;
  }

  .file-row .meta:last-child {
    display: none;
  }

  .select-cell {
    align-self: center;
    grid-row: auto;
    padding-top: 0;
  }

  .file-icon {
    width: 24px;
    height: 24px;
    flex-basis: 24px;
    font-size: 10px;
  }

  .file-name {
    font-size: 13px;
  }

  .gallery-grid {
    grid-template-columns: 1fr;
  }

  .lightbox-actions .action {
    flex: 1 1 120px;
  }
}

/* Gallery modes */
.impact-page {
  min-height: 100vh;
  background: var(--md-sys-color-background);
}

.impact-shell {
  width: min(1320px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 18px 0 32px;
}

body[data-gallery-mode="single"] .impact-shell {
  width: 100vw;
  padding: 0;
}

.impact-topbar,
.impact-toolbar,
.impact-section-head,
.impact-nav,
.impact-controls,
.impact-lightbox-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.impact-topbar {
  position: sticky;
  top: 10px;
  z-index: 20;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 8px;
  background: color-mix(in srgb, var(--md-sys-color-surface) 88%, transparent);
  box-shadow: var(--md-elevation-1);
  backdrop-filter: blur(14px);
}

.impact-brand {
  min-width: 0;
}

.impact-brand h1 {
  font-size: clamp(24px, 3.4vw, 38px);
}

.impact-kicker {
  margin: 0 0 5px;
  color: var(--md-sys-color-primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.impact-nav {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.impact-toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 8px;
  background: color-mix(in srgb, var(--md-sys-color-surface) 94%, white);
  box-shadow: var(--md-elevation-1);
}

.impact-mode-group {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  min-height: 40px;
  padding: 3px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 8px;
  background: var(--md-sys-color-surface-container-low);
}

.impact-mode-button,
.impact-icon-link,
.impact-button,
.impact-icon-button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
  text-decoration: none;
}

.impact-mode-button {
  padding: 6px 14px;
  background: transparent;
  font-weight: 800;
}

.impact-mode-button.active {
  background: var(--md-sys-color-surface);
  border-color: var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-primary);
  box-shadow: var(--md-elevation-1);
}

.impact-icon-link,
.impact-icon-button {
  width: 40px;
  display: grid;
  place-items: center;
  background: var(--md-sys-color-surface);
  border-color: var(--md-sys-color-outline-variant);
  font-size: 22px;
  font-weight: 800;
}

.impact-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 14px;
  border-color: var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface);
  font-weight: 800;
}

.impact-button.primary {
  border-color: var(--md-sys-color-primary);
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.impact-icon-link:hover,
.impact-button:hover,
.impact-icon-button:hover,
.impact-mode-button:hover,
.impact-thumb:hover,
.impact-card:hover {
  border-color: var(--md-sys-color-primary);
}

.impact-icon-link:focus-visible,
.impact-button:focus-visible,
.impact-icon-button:focus-visible,
.impact-mode-button:focus-visible,
.impact-thumb:focus-visible,
.impact-card:focus-visible,
.impact-search input:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.impact-search {
  flex: 1 1 240px;
  max-width: 420px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 13px;
  font-weight: 800;
}

.impact-search input {
  min-height: 38px;
  width: 100%;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 8px;
  padding: 7px 10px;
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
}

.impact-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 13px;
  font-weight: 750;
}

.impact-stats span {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 8px;
  background: var(--md-sys-color-surface-container-low);
  white-space: nowrap;
}

.impact-stats strong {
  color: var(--md-sys-color-on-surface);
  font-size: 18px;
}

.impact-single-view[hidden],
.impact-section[hidden],
.impact-empty[hidden] {
  display: none;
}

.impact-single-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 22.5em;
  min-height: 100vh;
  background: var(--md-sys-color-surface-container-low);
}

.impact-viewer {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 100vh;
  overflow: hidden;
  background: var(--md-sys-color-surface-container-low);
}

.impact-viewer img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  object-position: center center;
}

.impact-side-panel {
  min-width: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 18px;
  padding: 34px 18px 18px;
  overflow: hidden;
  background: color-mix(in srgb, var(--md-sys-color-surface) 96%, white);
  border-left: 1px solid var(--md-sys-color-outline-variant);
  box-shadow: -10px 0 28px rgba(0, 0, 0, 0.08);
  text-align: right;
}

.impact-side-panel .impact-brand h1 {
  font-size: clamp(26px, 3vw, 40px);
}

.impact-side-panel .impact-nav {
  justify-content: flex-end;
}

.impact-stage-button {
  position: absolute;
  top: 50%;
  z-index: 2;
  width: 44px;
  height: 58px;
  transform: translateY(-50%);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(17, 19, 24, 0.58);
  color: #ffffff;
  cursor: pointer;
  font-size: 38px;
  line-height: 1;
}

.impact-stage-button.prev {
  left: 14px;
}

.impact-stage-button.next {
  right: 14px;
}

.impact-rail {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-content: start;
  overflow: auto;
  padding: 2px;
}

.impact-thumb {
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  position: relative;
  box-sizing: border-box;
  border: 2px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  background: var(--md-sys-color-surface-container-low);
  cursor: pointer;
}

.impact-thumb.active {
  border-color: var(--md-sys-color-primary);
}

.impact-thumb img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.impact-thumb span {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 18px 7px 6px;
  overflow: hidden;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.72), transparent);
  color: #ffffff;
  font-size: 11px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.impact-section {
  padding: 10px 0 0;
}

.impact-section-head {
  justify-content: space-between;
  margin-bottom: 14px;
}

.impact-section-head h2 {
  margin: 0;
  font-size: clamp(24px, 3vw, 36px);
}

.impact-meta {
  margin: 0;
  color: var(--md-sys-color-on-surface-variant);
  font-weight: 750;
}

.impact-grid {
  position: relative;
  min-height: 240px;
  margin-bottom: 40px;
}

.impact-loading,
.impact-empty {
  padding: 44px 16px;
  color: var(--md-sys-color-on-surface-variant);
  text-align: center;
}

.impact-card {
  position: absolute;
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 4px;
  overflow: hidden;
  background: var(--md-sys-color-surface-container-low);
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
  text-align: left;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  opacity: 0;
  transform: var(--tilt, translateY(12px));
  transform-style: preserve-3d;
  transition:
    left 260ms ease,
    top 260ms ease,
    width 260ms ease,
    height 260ms ease,
    opacity 360ms ease var(--card-delay, 0ms),
    box-shadow 220ms ease,
    transform 220ms ease;
  will-change: left, top, width, height, transform;
}

.impact-card:hover {
  box-shadow: 0 14px 35px rgba(0, 0, 0, 0.2);
}

.impact-card.loaded {
  opacity: 1;
  transform: var(--tilt, translateY(0));
}

.impact-card img {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  background: transparent;
  opacity: 0;
  filter: blur(5px);
  transform: scale(1.16) translateZ(20px);
  transform-style: preserve-3d;
  transition:
    opacity 420ms ease,
    filter 420ms ease,
    transform 420ms ease;
}

.impact-card.loaded img {
  opacity: 1;
  filter: blur(0);
  transform: scale(1);
}

.impact-card-info {
  position: absolute;
  z-index: 3;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  gap: 3px;
  padding: 36px 12px 10px;
  background: linear-gradient(to bottom, transparent 0%, rgba(0, 0, 0, 0.72) 82%);
  color: #ffffff;
  opacity: 0;
  transform: translateY(100%);
  transition:
    opacity 380ms cubic-bezier(0.175, 0.885, 0.32, 1.275),
    transform 380ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
  backdrop-filter: blur(4px);
}

.impact-card:hover .impact-card-info,
.impact-card:focus-visible .impact-card-info {
  opacity: 1;
  transform: translateY(0);
}

.impact-card-info strong,
.impact-card-info small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.impact-card-info small {
  color: rgba(255, 255, 255, 0.78);
}

.impact-lightbox {
  width: min(1180px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  padding: 0;
  border: 0;
  border-radius: 8px;
  overflow: hidden;
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  box-shadow: var(--md-elevation-3);
}

.impact-lightbox::backdrop {
  background: rgba(17, 19, 24, 0.74);
}

.impact-lightbox-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.impact-lightbox-toolbar strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.impact-lightbox img {
  width: 100%;
  max-height: calc(100vh - 172px);
  display: block;
  object-fit: contain;
  background: var(--md-sys-color-surface-container-low);
}

.impact-lightbox-actions {
  justify-content: center;
  padding: 14px;
  flex-wrap: wrap;
}

@media (max-width: 760px) {
  .impact-shell {
    width: min(100vw - 20px, 1320px);
    padding-top: 12px;
  }

  body[data-gallery-mode="single"] .impact-shell {
    width: 100vw;
    padding: 0;
  }

  .impact-topbar {
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
    top: 8px;
  }

  .impact-nav {
    width: 100%;
    justify-content: flex-start;
  }

  .impact-toolbar {
    position: static;
    align-items: stretch;
  }

  .impact-search,
  .impact-controls,
  .impact-stats {
    width: 100%;
    max-width: none;
  }

  .impact-controls .impact-button,
  .impact-stats span {
    flex: 1 1 0;
  }

  .impact-single-view {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(360px, 68vh) minmax(190px, 32vh);
    min-height: 0;
  }

  .impact-viewer {
    min-height: 0;
  }

  .impact-side-panel {
    height: auto;
    min-height: 0;
    grid-template-rows: auto auto minmax(0, 1fr);
    gap: 10px;
    padding: 12px;
    border-left: 0;
    border-top: 1px solid var(--md-sys-color-outline-variant);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.08);
    text-align: left;
  }

  .impact-side-panel .impact-brand {
    display: none;
  }

  .impact-side-panel .impact-nav {
    width: 100%;
    justify-content: flex-start;
  }

  .impact-rail {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 6px;
  }

  .impact-thumb {
    flex: 0 0 92px;
    width: 92px;
    height: 92px;
    aspect-ratio: auto;
  }

  .impact-viewer {
    min-height: 0;
  }

  .impact-stage-button {
    width: 38px;
    height: 50px;
    font-size: 32px;
  }

  .impact-section-head {
    align-items: start;
    flex-direction: column;
  }

  .impact-grid {
    min-height: 220px;
  }

  .impact-lightbox-actions .impact-button {
    flex: 1 1 100px;
  }
}
