.files {
    width: 100%;
}

.file-container {
    position: relative;
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr) 68px 60px;
    grid-template-rows: 1fr 1fr;
    align-items: center;
    column-gap: 16px;
    row-gap: 2px;
    min-height: 82px;
    padding: 12px 0;
    border-bottom: 1px solid var(--divider);
    transition: color 120ms ease, background-color 120ms ease, opacity 120ms ease;
}

.file-container.accepts-stl.dragover {
    background: rgba(79, 143, 172, 0.1);
    box-shadow: inset 0 0 0 1px rgba(79, 143, 172, 0.45);
}

.file-container.is-processing {
    cursor: progress;
}

.file-container.is-short-dicom {
    opacity: 0.5;
}

.file-container.is-short-dicom:hover {
    opacity: 1;
}

.file-container.is-processing > :not(.file-processing-overlay):not(.file-facepoint-controls) {
    opacity: 0.38;
    filter: grayscale(1);
    pointer-events: none;
}

.file-processing-overlay {
    position: absolute;
    z-index: 3;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(245, 245, 241, 0.42);
    color: rgba(17, 17, 15, 0.62);
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    pointer-events: none;
}

.file-preview {
    grid-column: 1;
    grid-row: 1 / 3;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 58px;
    height: 58px;
    overflow: hidden;
    background: var(--soft-grey);
}

.file-preview canvas {
    display: block;
    width: 58px;
    height: 58px;
    border: 1px solid var(--divider);
    border-radius: 0;
}

.file-preview.is-empty {
    width: 58px;
    height: 58px;
    background: var(--blue);
}

.file-preview.is-empty::after {
    content: "MESH";
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.file-name {
    grid-column: 2;
    grid-row: 1 / 3;
    min-width: 0;
    text-align: left;
}

.file-name-row {
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 14px;
}

.series-link {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font: inherit;
    text-align: left;
}

.series-link:hover:not(:disabled) {
    color: var(--blue);
}

.series-link:disabled,
.file-remove-icon:disabled {
    cursor: default;
}

.series-link:disabled .series-link-title::after {
    content: "";
}

.series-link-title {
    display: block;
    max-width: 100%;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.series-link-title::after {
    content: "  ↗";
    color: var(--red);
    font-family: var(--mono);
    font-size: 11px;
}

.series-link-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 4px 14px;
    max-width: 100%;
    margin-top: 7px;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.025em;
    line-height: 1.35;
    text-transform: uppercase;
}

.series-link-meta-item {
    display: inline-block;
}

.file-type {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.file-optimized-icon {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    color: rgba(17, 17, 15, 0.34);
    font-size: 10px;
    line-height: 1;
}

.file-meta {
    grid-column: 3;
    grid-row: 1 / 3;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 6px;
    min-width: 0;
    font-family: var(--mono);
}

.file-modality {
    min-width: 0;
    padding: 0;
    background: transparent;
    color: rgba(17, 17, 15, 0.34);
    font-size: 9px;
    font-weight: 400;
    letter-spacing: 0.08em;
    line-height: 1;
    text-align: center;
}

.file-size {
    color: var(--muted);
    font-size: 10px;
    line-height: 1.2;
}

.file-size::after {
    content: " FILES";
}

.file-size.is-hidden,
.file-modality.is-hidden {
    display: none;
}

.file-remove-icon {
    grid-column: 4;
    grid-row: 2;
    align-self: start;
    justify-self: center;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 0;
    background: transparent;
    color: transparent;
    cursor: pointer;
    text-align: center;
}

.file-container:not(.is-processing):hover .file-remove-icon {
    color: var(--muted);
}

.file-remove-icon:hover {
    background: transparent;
    color: var(--red);
}

.file-remove-icon:focus-visible {
    color: var(--red);
}

.file-facepoint-controls {
    grid-column: 4;
    grid-row: 1;
    align-self: end;
    justify-self: center;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    min-height: 28px;
}

.file-facepoint-anchor,
.file-stl-upload {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: rgba(17, 17, 15, 0.4);
    cursor: pointer;
}

.file-facepoint-anchor:hover:not(:disabled),
.file-stl-upload:hover:not(:disabled) {
    background: transparent;
    color: var(--ink);
}

.file-facepoint-anchor:disabled,
.file-stl-upload:disabled {
    cursor: default;
    opacity: 0.65;
}

.file-stl-list {
    grid-column: 2 / 5;
    grid-row: 3;
    display: flex;
    flex-wrap: wrap;
    gap: 5px 14px;
    min-width: 0;
    padding-top: 7px;
}

.file-stl-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    max-width: 100%;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 10px;
    line-height: 1.35;
    text-decoration: none;
}

.file-stl-link:hover {
    color: var(--blue);
}

.file-stl-link.is-building {
    opacity: 0.65;
}

.file-stl-link.is-failed {
    color: var(--red);
}

.file-facepoint-anchor.is-pending {
    background: transparent;
    color: var(--red);
}

.file-facepoint-anchor.is-ok {
    background: transparent;
    color: #4f8fac;
}

.file-facepoint-anchor.is-error {
    background: transparent;
    color: var(--red);
}

.file-facepoint-anchor-3d {
    width: auto;
    height: auto;
    min-width: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: default;
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.file-facepoint-anchor-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.file-facepoint-anchor.is-pending .file-facepoint-anchor-icon {
    opacity: 0;
}

.file-facepoint-anchor.is-pending::after {
    position: absolute;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(210, 45, 32, 0.25);
    border-top-color: var(--red);
    border-radius: 50%;
    content: "";
    animation: facepoint-spin 0.8s linear infinite;
}

@keyframes facepoint-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 560px) {
    .file-container {
        grid-template-columns: 48px minmax(0, 1fr) 48px;
        grid-template-rows: 1fr;
        column-gap: 12px;
        row-gap: 0;
        padding-right: 62px;
    }

    .file-preview,
    .file-name {
        grid-row: 1;
    }

    .file-preview,
    .file-preview canvas,
    .file-preview.is-empty {
        width: 48px;
        height: 48px;
    }

    .file-meta {
        grid-column: 3;
        grid-row: 1;
        align-items: flex-end;
    }

    .file-facepoint-controls {
        position: absolute;
        top: 4px;
        right: 0;
    }

    .file-remove-icon {
        position: absolute;
        top: auto;
        right: 0;
        bottom: 4px;
        margin: 0;
        color: var(--muted);
    }

    .file-stl-list {
        grid-column: 2 / 4;
        grid-row: 2;
    }

    .file-name-row {
        gap: 9px;
    }

    .series-link-title {
        font-size: 13px;
    }

    .series-link-meta {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .file-facepoint-anchor.is-pending::after {
        animation: none;
    }
}
