/* ── Edit mode ── */
#controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

#count-label {
    font-size: 0.75rem;
    color: #888;
    margin-left: auto;
}

#queue-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}

#empty-state {
    grid-column: 1 / -1;
    padding: 36px 16px;
    text-align: center;
    color: #aaa;
    font-size: 0.8rem;
    border: 2px dashed #ccc;
    border-radius: 8px;
}

.q-card {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    background: #ddd;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.q-card:active { cursor: grabbing; }
.q-card.dragging { display: none; }

/* Fit (contain) mode — image letterboxed inside the square */
#queue-grid.fmt-contain .q-card { background: #111; }
#queue-grid.fmt-contain .q-card img { object-fit: contain; }

.q-spacer {
    aspect-ratio: 1;
    border: 2px dashed #4af;
    border-radius: 8px;
    background: rgba(68, 170, 255, 0.07);
    pointer-events: none;
}

.q-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

.q-badge {
    position: absolute;
    top: 5px;
    left: 5px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 3px;
    pointer-events: none;
}

.q-rm {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    padding: 0;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.q-rm:hover { background: rgba(180,0,0,0.8); }

/* trailing drop zone — invisible, just catches drops past the last card */
.q-trail {
    grid-column: 1 / -1;
    height: 36px;
}

#action-row { margin-top: 18px; }

/* QR / link row */
#link-row {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 14px 16px;
    background: #1a1a1a;
    border-radius: 8px;
    color: #fff;
    font-size: 13px;
    margin-top: 14px;
}

#link-row canvas, #link-row img { display: block; flex-shrink: 0; }
#link-row a { color: #4af; word-break: break-all; font-size: 0.75rem; }

/* ── View mode ── */
#view-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
    margin-top: 16px;
}

.v-card {
    border-radius: 8px;
    overflow: hidden;
    background: #111;
}

.v-card img { width: 100%; height: auto; display: block; }

.v-bar {
    display: flex;
    gap: 8px;
    padding: 8px 10px;
    background: #1a1a1a;
}

.v-bar a, .v-bar button {
    font-size: 0.75rem;
    padding: 5px 12px;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
}

.v-bar a {
    background: #333;
    color: #fff;
    border: 1px solid #555;
}

.v-bar button {
    background: transparent;
    color: #fff;
    border: 1px solid #555;
}

.v-bar a:hover, .v-bar button:hover { border-color: #aaa; }

/* ── Lightbox ── */
#lightbox {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0, 0, 0, 0.93);
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: pan-y;
}

#lightbox[hidden] { display: none; }

#lb-img {
    max-height: 80vh;
    max-width: 90vw;
    object-fit: contain;
    display: block;
    border-radius: 4px;
    pointer-events: none;
    user-select: none;
}

.lb-btn {
    position: fixed;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    cursor: pointer;
    border-radius: 6px;
    line-height: 1;
    transition: background 0.12s;
}

.lb-btn:hover { background: rgba(255, 255, 255, 0.25); }

/* Offsets keep the lightbox controls clear of the iOS notch / home indicator
   (env() is 0 on devices without safe areas, so positions are unchanged there). */
#lb-close {
    top: calc(16px + env(safe-area-inset-top));
    right: calc(16px + env(safe-area-inset-right));
    font-size: 1.4rem;
    padding: 6px 11px;
}

#lb-prev {
    left: calc(12px + env(safe-area-inset-left));
    top: 50%;
    transform: translateY(-50%);
    font-size: 2rem;
    padding: 16px 14px;
}

#lb-next {
    right: calc(12px + env(safe-area-inset-right));
    top: 50%;
    transform: translateY(-50%);
    font-size: 2rem;
    padding: 16px 14px;
}

#lb-counter {
    position: fixed;
    bottom: calc(20px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.82rem;
    pointer-events: none;
}

/* format select — matches shared button style from instautils.css */
#format-select {
    font-family: inherit;
    font-size: 0.8rem;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid #bbb;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

@media (prefers-color-scheme: dark) {
    .q-card { background: #333; }
    #empty-state { border-color: #444; color: #666; }
    #format-select { border-color: #555; }
}
