.pet-media-viewer {
    position: absolute;
    left: 830px;
    top: 34px;
    width: 718px;
    height: 187px;
    overflow: hidden;
    border: 1px solid #83a49a;
    background: #e9eeee;
    color: #183449;
    box-shadow: inset 0 0 0 3px #d8e3e1;
}

.pet-media-viewer:focus {
    outline: 2px solid #d59a22;
    outline-offset: 1px;
}

.pet-media-viewer-stage {
    position: absolute;
    inset: 4px 4px 31px;
    overflow: hidden;
    background: #18252c;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pet-media-viewer-gallery {
    width: calc(100% - 82px);
    height: 100%;
    padding: 5px 0;
    box-sizing: border-box;
    display: grid;
    gap: 6px;
    align-items: stretch;
}

.pet-media-viewer-gallery[hidden],
.pet-media-viewer-empty[hidden],
.pet-media-viewer-lightbox[hidden],
.pet-media-viewer-lightbox img[hidden],
.pet-media-viewer-lightbox video[hidden] {
    display: none !important;
}

.pet-media-viewer-gallery.count-1 { grid-template-columns: minmax(0, 1fr); }
.pet-media-viewer-gallery.count-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pet-media-viewer-gallery.count-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pet-media-viewer-gallery.count-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.pet-media-viewer-gallery.count-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }

.pet-media-viewer-tile {
    position: relative;
    min-width: 0;
    height: 100%;
    overflow: hidden;
    padding: 0;
    border: 1px solid #aec3c2;
    border-radius: 3px;
    background: #0f1c22;
    cursor: zoom-in;
}

.pet-media-viewer-tile:hover,
.pet-media-viewer-tile:focus-visible {
    border-color: #ffd36a;
    box-shadow: 0 0 0 2px #d59a22;
    outline: 0;
}

.pet-media-viewer-tile-media {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    background: #18252c;
    object-fit: contain;
}

.pet-media-viewer-tile-order,
.pet-media-viewer-video-badge {
    position: absolute;
    z-index: 1;
    border-radius: 2px;
    background: rgba(8, 28, 37, .82);
    color: #fff;
    line-height: 20px;
}

.pet-media-viewer-tile-order {
    right: 4px;
    bottom: 4px;
    min-width: 20px;
    height: 20px;
    padding: 0 4px;
    box-sizing: border-box;
    text-align: center;
}

.pet-media-viewer-video-badge {
    left: 50%;
    top: 50%;
    padding: 2px 7px;
    font-weight: bold;
    transform: translate(-50%, -50%);
    white-space: nowrap;
}

.pet-media-viewer-tile.is-unavailable::after {
    content: "無法顯示";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #edf2f2;
    color: #970020;
}

.pet-media-viewer-empty {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: #eef2f2;
    color: #65757d;
    text-align: center;
}

.pet-media-viewer-empty-title {
    color: #3e5964;
    font-size: 15px;
    font-weight: bold;
}

.pet-media-viewer-empty-note {
    font-size: 12px;
}

.pet-media-viewer-arrow {
    position: absolute;
    z-index: 2;
    top: 62px;
    width: 32px;
    height: 52px;
    padding: 0;
    border: 1px solid rgba(255,255,255,.75);
    border-radius: 4px;
    background: rgba(15,35,45,.72);
    color: #fff;
    font-family: Arial, sans-serif;
    font-size: 34px;
    font-weight: normal;
    line-height: 43px;
    text-align: center;
    cursor: pointer;
}

.pet-media-viewer-arrow.previous { left: 8px; }
.pet-media-viewer-arrow.next { right: 8px; }

.pet-media-viewer-arrow:hover:not(:disabled),
.pet-media-viewer-arrow:focus-visible {
    background: rgba(13,91,113,.92);
    outline: 2px solid #ffd36a;
    outline-offset: 1px;
}

.pet-media-viewer-arrow:disabled {
    opacity: .2;
    cursor: default;
}

.pet-media-viewer-footer {
    position: absolute;
    left: 4px;
    right: 4px;
    bottom: 3px;
    height: 27px;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 5px;
    border-top: 1px solid #a9b9b9;
    box-sizing: border-box;
    background: #f8fbfb;
    line-height: 23px;
}

.pet-media-viewer-group-button {
    height: 21px;
    padding: 0 5px;
    border: 1px solid #8da9a4;
    border-radius: 2px;
    background: #eef8f1;
    color: #174e43;
    font-size: 11px;
    line-height: 18px;
    white-space: nowrap;
}

.pet-media-viewer-group-button:disabled {
    opacity: .38;
}

.pet-media-viewer-group-count {
    min-width: 92px;
    color: #24594d;
    font-weight: bold;
    text-align: center;
    white-space: nowrap;
}

.pet-media-viewer-label {
    min-width: 0;
    flex: 1;
    overflow: hidden;
    color: #34505c;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pet-media-viewer-count {
    min-width: 92px;
    color: #24594d;
    font-weight: bold;
    text-align: right;
    white-space: nowrap;
}

.pet-media-viewer.is-error .pet-media-viewer-empty-title {
    color: #970020;
}

/* R5 layout: the compact storage card sits 20px farther left than R4b. */
.pet-media-storage-card {
    left: 1558px;
    width: 292px;
}

.pet-media-storage-detail {
    overflow-wrap: anywhere;
}

.pet-media-storage-card .pet-media-storage-actions button {
    min-width: 0;
    flex: 1 1 0;
    padding-right: 5px;
    padding-left: 5px;
    white-space: nowrap;
}

.pet-media-viewer-lightbox {
    position: fixed;
    z-index: 100050;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    background: rgba(7, 18, 24, .82);
}

.pet-media-viewer-lightbox-dialog {
    width: min(1000px, calc(100vw - 40px));
    height: min(760px, calc(100vh - 40px));
    overflow: hidden;
    display: grid;
    grid-template-rows: 44px minmax(0, 1fr) 36px;
    border: 1px solid #9bb8b0;
    border-radius: 5px;
    background: #f6fbf9;
    box-shadow: 0 18px 60px rgba(0,0,0,.45);
}

.pet-media-viewer-lightbox-head,
.pet-media-viewer-lightbox-footer {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 14px;
    color: #21483e;
}

.pet-media-viewer-lightbox-head {
    border-bottom: 1px solid #afc4bd;
    font-size: 17px;
}

.pet-media-viewer-lightbox-head strong,
.pet-media-viewer-lightbox-footer span {
    min-width: 0;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pet-media-viewer-lightbox-head button {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #21483e;
    font-size: 28px;
    line-height: 28px;
    cursor: pointer;
}

.pet-media-viewer-lightbox-stage {
    position: relative;
    min-height: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #101a20;
}

.pet-media-viewer-lightbox-stage img,
.pet-media-viewer-lightbox-stage video {
    display: block;
    width: calc(100% - 110px);
    height: calc(100% - 20px);
    max-width: calc(100% - 110px);
    max-height: calc(100% - 20px);
    object-fit: contain;
    background: #101a20;
}

.pet-media-viewer-lightbox-arrow {
    position: absolute;
    z-index: 2;
    top: 50%;
    width: 42px;
    height: 62px;
    padding: 0;
    border: 1px solid rgba(255,255,255,.7);
    border-radius: 4px;
    background: rgba(12, 39, 50, .8);
    color: #fff;
    font-size: 40px;
    line-height: 52px;
    transform: translateY(-50%);
    cursor: pointer;
}

.pet-media-viewer-lightbox-arrow.previous { left: 14px; }
.pet-media-viewer-lightbox-arrow.next { right: 14px; }
.pet-media-viewer-lightbox-arrow:disabled { opacity: .22; cursor: default; }

.pet-media-viewer-lightbox-footer {
    border-top: 1px solid #afc4bd;
    font-size: 13px;
}
