@layer features {
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.content-library {
  display: grid;
  gap: var(--lumi-space-5);
}

.resource-storage-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) repeat(3, minmax(10rem, 1fr));
  gap: var(--lumi-space-3);
}

.resource-storage-card {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: var(--lumi-space-2);
  padding: var(--lumi-space-4);
  border: 1px solid var(--lumi-border);
  border-radius: var(--lumi-radius-md);
  background: var(--lumi-surface-subtle);
}

.resource-storage-card > span:first-child {
  color: var(--lumi-text-muted);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.resource-storage-card strong {
  overflow-wrap: anywhere;
  font-family: var(--lumi-font-display);
  font-size: clamp(1.2rem, 2vw, 1.7rem);
}

.resource-storage-card small,
.resource-storage-card p {
  margin: 0;
  color: var(--lumi-text-muted);
}

.resource-storage-primary {
  background:
    linear-gradient(125deg, color-mix(in srgb, var(--lumi-primary) 12%, transparent), transparent 65%),
    var(--lumi-surface-subtle);
}

.resource-meter {
  width: 100%;
  height: 0.55rem;
  overflow: hidden;
  border-radius: var(--lumi-radius-pill);
  background: color-mix(in srgb, var(--lumi-border) 78%, transparent);
}

.resource-meter > span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--lumi-primary), var(--lumi-accent));
  transition: width 180ms ease;
}

.resource-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(18rem, 0.8fr);
  gap: var(--lumi-space-4);
  align-items: start;
}

.resource-upload-panel,
.resource-settings-panel {
  min-width: 0;
  padding: var(--lumi-space-4);
  border: 1px solid var(--lumi-border);
  border-radius: var(--lumi-radius-md);
  background: var(--lumi-surface-subtle);
}

.resource-upload-panel h2,
.resource-browser-header h2 {
  margin-bottom: var(--lumi-space-1);
}

.resource-upload-panel form {
  display: grid;
  gap: var(--lumi-space-3);
}

.resource-dropzone {
  min-height: 12rem;
  display: grid;
  place-items: center;
  align-content: center;
  gap: var(--lumi-space-2);
  padding: var(--lumi-space-5);
  border: 2px dashed color-mix(in srgb, var(--lumi-primary) 48%, var(--lumi-border));
  border-radius: var(--lumi-radius-md);
  background: color-mix(in srgb, var(--lumi-primary) 5%, var(--lumi-surface));
  color: var(--lumi-text);
  text-align: center;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.resource-dropzone:hover,
.resource-dropzone.is-dragging {
  border-color: var(--lumi-primary);
  background: color-mix(in srgb, var(--lumi-primary) 11%, var(--lumi-surface));
}

.resource-dropzone.is-dragging {
  transform: translateY(-2px);
}

.resource-dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.resource-dropzone-icon {
  width: 2.8rem;
  height: 2.8rem;
  display: grid;
  place-items: center;
  border-radius: var(--lumi-radius-pill);
  background: var(--lumi-primary);
  color: var(--lumi-button-text);
  font-size: 1.6rem;
  line-height: 1;
}

.resource-dropzone small,
.resource-dropzone > span:not(.resource-dropzone-icon) {
  color: var(--lumi-text-muted);
}

.resource-selected-files {
  display: grid;
  gap: var(--lumi-space-2);
  max-height: 12rem;
  overflow: auto;
  padding: var(--lumi-space-2);
  border: 1px solid var(--lumi-border);
  border-radius: var(--lumi-radius-sm);
  background: var(--lumi-surface);
}

.resource-selected-file {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--lumi-space-3);
  min-width: 0;
  padding: var(--lumi-space-2);
  border-bottom: 1px solid var(--lumi-border);
}

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

.resource-selected-file span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.resource-selected-file small {
  flex: 0 0 auto;
  color: var(--lumi-text-muted);
}

.resource-upload-options {
  display: flex;
  align-items: end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--lumi-space-3);
}

.resource-upload-options .field {
  flex: 1 1 18rem;
  margin: 0;
}

.resource-upload-progress {
  display: grid;
  gap: var(--lumi-space-2);
}

.resource-status {
  min-height: 1.5em;
  margin: 0;
  color: var(--lumi-text-muted);
}

.resource-status.is-error,
.resource-preview-error {
  color: var(--lumi-danger);
}

.resource-status.is-success {
  color: var(--lumi-success, var(--lumi-primary));
}

.resource-browser-status:empty {
  display: none;
}

.resource-settings-panel > summary {
  min-height: var(--lumi-control-height);
  display: flex;
  align-items: center;
  font-weight: 800;
  cursor: pointer;
}

.resource-settings-panel > summary > span {
  min-width: 0;
  display: grid;
  gap: var(--lumi-space-1);
}

.resource-settings-panel[open] > summary {
  margin-bottom: var(--lumi-space-4);
}

.resource-format-groups {
  display: grid;
  gap: var(--lumi-space-2);
  margin-top: var(--lumi-space-4);
}

.resource-format-groups > div {
  display: grid;
  gap: var(--lumi-space-1);
  padding: var(--lumi-space-2) 0;
  border-top: 1px solid var(--lumi-border);
}

.resource-format-groups span {
  color: var(--lumi-text-muted);
  overflow-wrap: anywhere;
}

.resource-browser-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--lumi-space-3);
}

.resource-browser-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--lumi-space-2);
}

.resource-browser-controls input,
.resource-browser-controls select {
  min-width: 10rem;
}

.resource-search input {
  min-width: min(18rem, 68vw);
}

.resource-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr));
  gap: var(--lumi-space-4);
}

.resource-empty-state {
  min-height: 0;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--lumi-space-2);
  padding: var(--lumi-space-3) var(--lumi-space-4);
  border: 1px dashed var(--lumi-border);
  border-radius: var(--lumi-radius-md);
  background: var(--lumi-surface-subtle);
  color: var(--lumi-text-muted);
}

.resource-empty-state strong {
  color: var(--lumi-text);
}

.resource-empty-state[hidden] {
  display: none !important;
}

.resource-card {
  min-width: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: 11rem minmax(0, 1fr);
  border: 1px solid var(--lumi-border);
  border-radius: var(--lumi-radius-md);
  background: var(--lumi-surface);
  box-shadow: var(--lumi-shadow-sm);
}

.resource-card[hidden] {
  display: none;
}

.resource-preview-tile {
  position: relative;
  width: 100%;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: var(--lumi-space-2);
  padding: 0;
  overflow: hidden;
  border: 0;
  border-bottom: 1px solid var(--lumi-border);
  border-radius: 0;
  background:
    radial-gradient(circle at 25% 15%, color-mix(in srgb, var(--lumi-primary) 16%, transparent), transparent 48%),
    var(--lumi-surface-subtle);
  color: var(--lumi-text-muted);
}

.resource-preview-tile:hover {
  background:
    radial-gradient(circle at 25% 15%, color-mix(in srgb, var(--lumi-primary) 24%, transparent), transparent 54%),
    var(--lumi-surface-raised);
}

.resource-preview-open {
  width: 100%;
  height: 100%;
  min-width: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: var(--lumi-space-2);
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.resource-preview-open:focus-visible {
  outline: 3px solid var(--lumi-focus);
  outline-offset: -3px;
}

.resource-preview-tile img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: repeating-conic-gradient(
    color-mix(in srgb, var(--lumi-border) 35%, transparent) 0 25%,
    transparent 0 50%
  ) 50% / 1rem 1rem;
}

.resource-preview-fallback-tile {
  padding: var(--lumi-space-3);
}

.resource-media-preview {
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.resource-media-preview.is-video::after {
  content: "";
  position: absolute;
  inset: 45% 0 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(transparent, rgb(0 0 0 / 72%));
}

.resource-media-preview video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #080a0c;
}

.resource-media-preview audio {
  display: none;
}

.resource-media-controls {
  position: absolute;
  right: var(--lumi-space-3);
  bottom: var(--lumi-space-3);
  left: var(--lumi-space-3);
  z-index: 2;
  min-width: 0;
  display: grid;
  justify-items: start;
  gap: var(--lumi-space-2);
  padding: var(--lumi-space-2);
  border-radius: var(--lumi-radius-sm);
  background: color-mix(in srgb, #07090b 78%, transparent);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transform: translateY(0.35rem);
  transition: opacity 160ms ease, transform 160ms ease;
}

.resource-media-preview.is-audio .resource-media-controls {
  background: color-mix(in srgb, var(--lumi-surface-raised) 90%, transparent);
  color: var(--lumi-text);
}

.resource-preview-tile:hover .resource-media-controls,
.resource-preview-tile:focus-within .resource-media-controls {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.resource-media-toggle {
  min-height: 2rem;
  padding-block: 0.3rem;
}

.resource-media-timeline {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--lumi-space-2);
}

.resource-media-timeline input {
  width: 100%;
  min-width: 0;
  min-height: 1.5rem;
  margin: 0;
  padding: 0;
}

.resource-media-timeline span {
  color: inherit;
  font-family: var(--lumi-font-mono);
  font-size: 0.7rem;
  white-space: nowrap;
}

.resource-type-mark {
  min-width: 4.5rem;
  min-height: 3.2rem;
  display: grid;
  place-items: center;
  padding: var(--lumi-space-2);
  border: 1px solid color-mix(in srgb, var(--lumi-primary) 35%, var(--lumi-border));
  border-radius: var(--lumi-radius-sm);
  background: color-mix(in srgb, var(--lumi-primary) 10%, var(--lumi-surface));
  color: var(--lumi-primary);
  font-family: var(--lumi-font-mono);
  font-weight: 800;
}

.resource-card-body {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: var(--lumi-space-3);
  padding: var(--lumi-space-4);
}

.resource-card-heading {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: var(--lumi-space-2);
}

.resource-card-heading > div {
  min-width: 0;
  overflow: hidden;
}

.resource-card-heading h3 {
  margin-bottom: var(--lumi-space-1);
  overflow-wrap: anywhere;
  font-size: 1.05rem;
}

.resource-card-heading p {
  margin: 0;
  display: -webkit-box;
  overflow: hidden;
  overflow-wrap: anywhere;
  color: var(--lumi-text-muted);
  font-size: 0.82rem;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.resource-card-heading .badge {
  max-width: 100%;
  flex: 0 0 auto;
  white-space: nowrap;
}

.resource-metadata {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--lumi-space-2);
  margin: 0;
}

.resource-metadata > div {
  min-width: 0;
  display: grid;
  gap: 0.15rem;
  padding: var(--lumi-space-2);
  border-radius: var(--lumi-radius-sm);
  background: var(--lumi-surface-subtle);
}

.resource-metadata dt {
  color: var(--lumi-text-muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.resource-metadata dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.resource-public-url {
  display: grid;
  gap: var(--lumi-space-1);
}

.resource-public-url[hidden] {
  display: none;
}

.resource-public-url > label {
  color: var(--lumi-text-muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.resource-url-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--lumi-space-2);
}

.resource-url-row .button {
  min-width: 0;
  max-width: 100%;
}

.resource-url-row input {
  min-width: 0;
  font-family: var(--lumi-font-mono);
  font-size: 0.76rem;
}

.resource-card-actions {
  min-width: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--lumi-space-2);
}

.resource-card-actions form {
  display: contents;
}

.resource-card-actions .button {
  min-width: 0;
  max-width: 100%;
}

.resource-edit-details {
  padding-top: var(--lumi-space-2);
  border-top: 1px solid var(--lumi-border);
}

.resource-edit-details > summary {
  min-height: 2.4rem;
  display: flex;
  align-items: center;
  color: var(--lumi-text-muted);
  font-weight: 700;
  cursor: pointer;
}

.resource-edit-details[open] > summary {
  margin-bottom: var(--lumi-space-3);
}

.resource-more-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: var(--lumi-space-3);
}

.resource-rename-form {
  min-width: 0;
  display: grid;
  justify-items: start;
  gap: var(--lumi-space-2);
}

.resource-rename-form label {
  width: 100%;
  min-width: 0;
  display: grid;
  gap: var(--lumi-space-1);
}

.resource-rename-submit {
  opacity: 0;
  visibility: hidden;
  transform: translateY(-0.25rem);
  transition: opacity 140ms ease, transform 140ms ease, visibility 140ms;
}

.resource-rename-submit.is-dirty {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.resource-delete-form {
  justify-self: end;
}

.resource-preview-modal {
  z-index: 90;
}

.resource-preview-dialog {
  width: min(94vw, 68rem);
  max-height: min(92vh, 58rem);
  display: grid;
  grid-template-rows: auto minmax(10rem, 1fr) auto auto;
  overflow: hidden;
}

.resource-preview-stage {
  min-height: 18rem;
  max-height: 68vh;
  display: grid;
  place-items: center;
  overflow: auto;
  border: 1px solid var(--lumi-border);
  border-radius: var(--lumi-radius-md);
  background:
    repeating-conic-gradient(
      color-mix(in srgb, var(--lumi-border) 25%, transparent) 0 25%,
      transparent 0 50%
    ) 50% / 1.25rem 1.25rem,
    var(--lumi-surface-subtle);
}

.resource-preview-stage img,
.resource-preview-stage video,
.resource-preview-stage iframe {
  width: 100%;
  height: 100%;
  max-height: 68vh;
  border: 0;
  object-fit: contain;
}

.resource-preview-stage audio {
  width: min(90%, 42rem);
}

.resource-preview-stage pre {
  width: 100%;
  min-height: 18rem;
  max-height: 65vh;
  margin: 0;
  padding: var(--lumi-space-4);
  overflow: auto;
  background: var(--lumi-surface);
  color: var(--lumi-text);
  white-space: pre-wrap;
  word-break: break-word;
}

.resource-font-preview {
  width: 100%;
  padding: var(--lumi-space-5);
  color: var(--lumi-text);
  font-size: clamp(1.6rem, 5vw, 4rem);
  line-height: 1.25;
  text-align: center;
}

.resource-preview-fallback {
  max-width: 36rem;
  padding: var(--lumi-space-5);
  color: var(--lumi-text-muted);
  text-align: center;
}

@media (max-width: 1120px) {
  .resource-storage-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .resource-workspace {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 680px) {
  .resource-storage-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .resource-upload-panel,
  .resource-settings-panel,
  .resource-card-body {
    padding: var(--lumi-space-3);
  }

  .resource-dropzone {
    min-height: 10rem;
    padding: var(--lumi-space-4);
  }

  .resource-browser-controls,
  .resource-browser-controls label,
  .resource-browser-controls input,
  .resource-browser-controls select {
    width: 100%;
  }

  .resource-card {
    grid-template-rows: 9rem minmax(0, 1fr);
  }

  .resource-card-actions > *,
  .resource-card-actions form,
  .resource-card-actions .button {
    flex: 1 1 auto;
  }

  .resource-rename-form,
  .resource-url-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .resource-more-actions {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .resource-preview-dialog {
    width: 100%;
    max-height: 96vh;
  }
}

@media (hover: none) {
  .resource-media-controls {
    opacity: 1;
    pointer-events: auto;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .resource-dropzone,
  .resource-meter > span,
  .resource-media-controls,
  .resource-rename-submit {
    transition: none;
  }
}
}
