* {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #020617;
  color: #e8f7ff;
}

html {
  min-height: 100%;
  background:
    radial-gradient(ellipse at 12% 0%, rgba(0, 115, 190, .25), transparent 38rem),
    radial-gradient(ellipse at 100% 28%, rgba(76, 61, 190, .16), transparent 34rem),
    #020617;
}

body {
  min-height: 100vh;
  margin: 0;
  color: #e8f7ff;
  background-image: linear-gradient(180deg, rgba(2, 6, 23, .15), rgba(2, 6, 23, .74));
}

button,
input,
select {
  font: inherit;
}

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

a {
  color: #8fe4ff;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid #b9f3ff;
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

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

.library-header,
.library-brand,
.library-header .back-link,
.section-heading,
.pagination,
.library-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.library-header {
  gap: 16px;
  padding: 10px 0 18px;
  border-bottom: 1px solid rgba(127, 216, 255, .18);
}

.library-brand {
  justify-content: flex-start;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.library-brand img {
  display: block;
  border: 1px solid rgba(127, 216, 255, .45);
  border-radius: 11px;
  box-shadow: 0 0 20px rgba(0, 180, 255, .23);
}

.library-brand span {
  display: grid;
  gap: 3px;
}

.library-brand strong {
  font-size: 14px;
  letter-spacing: .02em;
}

.library-brand small {
  color: #93a8bf;
  font-size: 12px;
}

.back-link {
  min-height: 42px;
  padding: 8px 13px;
  border: 1px solid rgba(127, 216, 255, .28);
  border-radius: 9px;
  background: rgba(10, 22, 40, .72);
  color: #cdefff;
  font-size: 13px;
  text-decoration: none;
  transition: border-color .15s ease, background .15s ease;
}

.back-link:hover {
  border-color: rgba(127, 216, 255, .72);
  background: rgba(12, 38, 60, .88);
}

.library-intro {
  padding: clamp(28px, 5vw, 56px) 0 26px;
}

.eyebrow {
  margin: 0 0 8px;
  color: #71dafa;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .16em;
}

.library-intro h1 {
  margin: 0;
  color: #effbff;
  font-size: clamp(32px, 5.5vw, 52px);
  letter-spacing: -.035em;
  line-height: 1.06;
  text-shadow: 0 0 24px rgba(41, 180, 255, .22);
}

.library-intro > p:last-child {
  max-width: 690px;
  margin: 12px 0 0;
  color: #afc1d3;
  font-size: 15px;
  line-height: 1.6;
}

.upload-card,
.notice-card {
  padding: clamp(16px, 3vw, 24px);
  border: 1px solid rgba(98, 201, 255, .27);
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(12, 28, 50, .94), rgba(5, 12, 27, .96));
  box-shadow: 0 18px 55px rgba(0, 0, 0, .23), inset 0 1px rgba(255, 255, 255, .035);
}

.notice-card {
  max-width: 600px;
  margin: 10px 0 28px;
}

.notice-card h2 {
  margin: 0;
}

.notice-card p {
  color: #afc1d3;
  line-height: 1.5;
}

.section-heading {
  gap: 14px;
  margin-bottom: 18px;
}

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

.section-heading .eyebrow {
  margin-bottom: 5px;
}

.upload-limit {
  flex: 0 0 auto;
  padding: 6px 9px;
  border: 1px solid rgba(127, 216, 255, .22);
  border-radius: 999px;
  color: #a9c0d4;
  font-size: 12px;
}

.upload-fields {
  display: grid;
  grid-template-columns: minmax(180px, .85fr) minmax(220px, 1.1fr) minmax(200px, 1.2fr) auto;
  align-items: end;
  gap: 13px;
}

.field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.field label {
  color: #d9eafa;
  font-size: 13px;
  font-weight: 650;
}

.optional,
.field small {
  color: #8095aa;
  font-size: 12px;
  font-weight: 400;
}

.field input,
.field select {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid rgba(127, 216, 255, .23);
  border-radius: 9px;
  background: rgba(3, 9, 21, .92);
  color: #e8f7ff;
}

.field select {
  cursor: pointer;
}

.field input[type="file"] {
  padding: 8px;
  color: #b8c7d9;
  font-size: 12px;
}

.field input[type="file"]::file-selector-button {
  margin-right: 8px;
  padding: 5px 8px;
  border: 1px solid rgba(127, 216, 255, .3);
  border-radius: 6px;
  background: rgba(26, 67, 95, .7);
  color: #e7f7ff;
  cursor: pointer;
}

.submit-field {
  display: flex;
}

.library-button,
.secondary-button,
.delete-image-button,
.category-filter {
  min-height: 42px;
  border-radius: 9px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .13s ease, filter .13s ease, border-color .13s ease, background .13s ease;
}

.library-button {
  padding: 10px 16px;
  border: 1px solid #a9f6ff;
  background: linear-gradient(180deg, #35cde6, #0787b4 68%, #045c87);
  color: #031622;
  box-shadow: 0 5px 0 #043650, 0 8px 17px rgba(0, 0, 0, .32), 0 0 18px rgba(0, 191, 255, .2);
  white-space: nowrap;
}

.library-button:hover:not(:disabled) {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.library-button:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #043650, 0 4px 10px rgba(0, 0, 0, .28);
}

.library-button:disabled,
.secondary-button:disabled,
.delete-image-button:disabled {
  cursor: wait;
  filter: grayscale(.35);
  opacity: .6;
}

.upload-guidance {
  max-width: 920px;
  margin: 15px 0 0;
  color: #8fa5bb;
  font-size: 12px;
  line-height: 1.55;
}

.inline-status,
.page-status {
  min-height: 1.35em;
  margin: 10px 0 0;
  color: #8fe4c6;
  font-size: 13px;
}

.inline-status.is-error,
.page-status.is-error {
  color: #ff9daf;
}

.browse-section {
  padding: 34px 0 0;
}

.browse-heading {
  align-items: end;
  margin-bottom: 14px;
}

.result-summary {
  margin: 0;
  color: #91a6bc;
  font-size: 13px;
  text-align: right;
}

.category-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 10px;
}

.category-filter {
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid rgba(127, 216, 255, .2);
  background: rgba(6, 18, 35, .8);
  color: #b8cada;
  font-size: 13px;
}

.category-filter:hover {
  border-color: rgba(127, 216, 255, .55);
  color: #e9f7ff;
}

.category-filter[aria-pressed="true"] {
  border-color: rgba(103, 228, 255, .8);
  background: linear-gradient(145deg, rgba(0, 159, 202, .35), rgba(35, 84, 139, .37));
  color: #eafaff;
  box-shadow: 0 0 14px rgba(0, 190, 255, .12);
}

.page-status {
  margin: 10px 0 14px;
  color: #91a6bc;
}

.retry-button {
  margin: 0 0 14px;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 235px), 1fr));
  align-items: start;
  gap: 16px;
}

.image-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(127, 216, 255, .19);
  border-radius: 13px;
  background: rgba(6, 15, 31, .95);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .23);
}

.image-card-image-wrap {
  position: relative;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  background:
    linear-gradient(135deg, rgba(32, 67, 96, .35), transparent),
    #06101f;
}

.image-card-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-card-image.is-broken {
  visibility: hidden;
}

.image-card-body {
  padding: 12px 13px 13px;
}

.image-card-caption {
  margin: 0;
  color: #e7f5ff;
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.image-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 8px;
  margin-top: 9px;
  color: #8499af;
  font-size: 11px;
  line-height: 1.4;
}

.image-card-category {
  color: #7bdaf7;
  font-weight: 700;
}

.image-card-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.delete-image-button {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid rgba(255, 133, 157, .28);
  background: rgba(105, 24, 47, .28);
  color: #ffb4c3;
  font-size: 12px;
}

.delete-image-button:hover:not(:disabled) {
  border-color: rgba(255, 133, 157, .68);
  background: rgba(145, 35, 61, .42);
}

.empty-state {
  padding: 42px 20px;
  border: 1px dashed rgba(127, 216, 255, .25);
  border-radius: 14px;
  background: rgba(4, 14, 29, .5);
  text-align: center;
}

.empty-icon {
  color: #69d5fa;
  font-size: 35px;
}

.empty-state h3 {
  margin: 7px 0;
  font-size: 16px;
}

.empty-state p {
  margin: 0;
  color: #94a8bd;
  font-size: 13px;
}

.pagination {
  justify-content: center;
  gap: 15px;
  padding: 22px 0 8px;
}

.secondary-button {
  padding: 8px 12px;
  border: 1px solid rgba(127, 216, 255, .28);
  background: rgba(8, 25, 45, .84);
  color: #d8efff;
  font-size: 13px;
}

.secondary-button:hover:not(:disabled) {
  border-color: rgba(127, 216, 255, .72);
  background: rgba(13, 46, 72, .92);
}

.page-number {
  min-width: 68px;
  color: #9db1c5;
  font-size: 13px;
  text-align: center;
}

.library-footer {
  gap: 12px;
  margin-top: 40px;
  padding-top: 16px;
  border-top: 1px solid rgba(127, 216, 255, .14);
  color: #788da2;
  font-size: 12px;
}

.library-footer a {
  color: #9cdcf2;
}

@media (max-width: 820px) {
  .upload-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .caption-field {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .library-shell {
    width: calc(100% - 24px);
    max-width: 1180px;
    padding-top: 12px;
  }

  .library-header {
    align-items: flex-start;
  }

  .library-brand img {
    width: 42px;
    height: 42px;
  }

  .library-brand strong {
    font-size: 12px;
  }

  .back-link {
    min-height: 38px;
    padding: 7px 9px;
    font-size: 11px;
  }

  .library-intro {
    padding: 28px 0 21px;
  }

  .library-intro > p:last-child {
    font-size: 14px;
  }

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

  .caption-field {
    grid-column: auto;
  }

  .submit-field,
  .submit-field .library-button {
    width: 100%;
  }

  .browse-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .result-summary {
    text-align: left;
  }

  .image-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .image-card-body {
    padding: 9px;
  }

  .image-card-caption {
    font-size: 12px;
  }

  .image-card-meta {
    font-size: 10px;
  }

  .library-footer {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 350px) {
  .image-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}
