/* Shared by the note sidebar and the standalone note gallery. */
.noteGallery {
    --gallery-panel: #101420;
    --gallery-border: #1e293b;
    --gallery-muted: #94a3b8;
    --gallery-text: #f8fafc;
    --gallery-accent: #38bdf8;
    width: 236px;
    flex: 0 0 236px;
    min-height: 0;
    padding: 16px 12px;
    box-sizing: border-box;
    border-left: 1px solid var(--gallery-border);
    background: var(--gallery-panel);
    color: var(--gallery-muted);
    font: 12px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
    overflow-y: auto;
}

.noteGallery[hidden],
.noteGallery [hidden] {
    display: none !important;
}

.galleryHeader {
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.galleryHeader h2 {
    margin: 0;
    color: var(--gallery-text);
    font-size: 14px;
    font-weight: 600;
}

.galleryCount {
    margin-left: 5px;
    padding: 1px 6px;
    border-radius: 4px;
    color: var(--gallery-accent);
    background: rgba(56, 189, 248, 0.08);
    font-size: 11px;
}

.noteGallery button {
    font: inherit;
    cursor: pointer;
}

.galleryClose {
    background: transparent;
    border: none;
    color: var(--gallery-muted);
    font-size: 22px !important;
    line-height: 24px !important;
    padding: 0 4px;
}

.galleryHint {
    margin: 9px 0 12px;
}

.galleryUpload {
    display: block;
    position: relative;
    padding: 11px 8px;
    border: 1px dashed #32516c;
    border-radius: 5px;
    background: rgba(56, 189, 248, 0.04);
    color: var(--gallery-accent);
    text-align: center;
    cursor: pointer;
}

.galleryUpload:hover,
.galleryUpload:focus-within,
.noteGallery.drag-over .galleryUpload {
    border-color: var(--gallery-accent);
    background: rgba(56, 189, 248, 0.1);
}

.galleryFileInput {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.galleryStatus {
    margin-top: 10px;
    color: #00ffd2;
    overflow-wrap: anywhere;
}

.galleryStatus:empty {
    display: none;
}

.galleryStatus.is-error {
    color: #fda4af;
}

.galleryRetry {
    margin-top: 8px;
    padding: 4px 9px;
    border: 1px solid var(--gallery-border);
    border-radius: 4px;
    color: var(--gallery-accent);
    background: transparent;
}

.galleryImages {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 14px;
}

.galleryCard {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--gallery-border);
    border-radius: 5px;
    background: #151a26;
}

.galleryCard:hover {
    border-color: #32516c;
}

.galleryPreview {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 88px;
    padding: 5px;
    box-sizing: border-box;
    background: #0a0d16;
    cursor: grab;
}

.galleryPreview:active {
    cursor: grabbing;
}

.galleryPreview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.galleryName {
    margin: 6px 7px 2px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 10px;
}

.galleryActions {
    display: flex;
    align-items: center;
    padding: 2px 4px 5px;
    gap: 2px;
}

.galleryActions button {
    border: none;
    border-radius: 3px;
    background: transparent;
    color: var(--gallery-accent);
    padding: 2px 3px;
    font-size: 10px;
}

.galleryActions button:hover {
    background: rgba(56, 189, 248, 0.1);
}

.galleryActions .galleryActionButton {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    height: 24px;
    padding: 4px;
    box-sizing: border-box;
    flex: 1 1 0;
}

.galleryActionButton svg {
    width: 16px;
    height: 16px;
    pointer-events: none;
}

.galleryActions button:last-child {
    color: #fda4af;
}

.galleryActions .galleryCopyButton {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    height: 24px;
    padding: 4px;
    box-sizing: border-box;
    flex: 1 1 0;
}

.galleryCopyButton svg {
    width: 16px;
    height: 16px;
    pointer-events: none;
}

.galleryCopyButton:focus-visible {
    outline: 2px solid var(--gallery-accent);
    outline-offset: 2px;
}

.galleryCopyButton[aria-busy="true"] {
    cursor: wait;
}

.galleryActions .galleryCopyButton[data-copy-state="success"] {
    color: #00ffd2;
}

.galleryActions .galleryCopyButton[data-copy-state="error"] {
    color: #fda4af;
}

.galleryEmpty {
    padding: 18px 4px;
    margin: 0;
    text-align: center;
}

.galleryPage {
    margin: 0;
    background: #101420;
}

.galleryPage .noteGallery {
    width: 100%;
    max-width: 760px;
    min-height: 100vh;
    margin: 0 auto;
    border: none;
}

.galleryPage .galleryImages {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}

@media (max-width: 1000px) and (min-width: 601px) {
    .noteWorkspace > .noteGallery {
        width: 200px;
        flex-basis: 200px;
        padding: 12px 8px;
    }
}

@media (max-width: 600px) {
    .noteWorkspace > .noteGallery {
        position: absolute;
        top: 47px;
        bottom: 34px;
        right: 0;
        width: min(260px, 82vw);
        z-index: 20;
        box-shadow: -8px 0 24px rgba(0, 0, 0, 0.4);
    }
}
