/* Toast notifications */
.toast-stack {
    position: fixed;
    top: calc(12px + env(safe-area-inset-top, 0px));
    right: 12px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: min(420px, calc(100vw - 24px));
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    padding: 10px 14px;
    border: 1px solid var(--border-strong);
    background: var(--surface-raised);
    color: var(--text);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    font-size: 13px;
    line-height: 1.4;
    cursor: pointer;
    animation: toast-in 0.2s ease;
}
.toast--success { border-color: #3a7a4a; background: var(--surface-raised); }
.toast--error { border-color: var(--danger); }
.toast--warn { border-color: var(--alert-border); background: var(--alert-bg); }
.toast--out { opacity: 0; transform: translateX(8px); transition: opacity 0.2s, transform 0.2s; }
@keyframes toast-in {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Explorer multi-select */
.explorer-select-wrap {
    position: absolute;
    top: 4px;
    left: 4px;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    background: color-mix(in srgb, var(--surface-raised) 88%, transparent);
    opacity: 0;
    transition: opacity 0.15s;
}
.tile:hover .explorer-select-wrap,
.tile.is-selected .explorer-select-wrap,
.explorer-item.is-selected .explorer-select-wrap,
.list-name:hover .explorer-select-wrap {
    opacity: 1;
}
@media (max-width: 768px) {
    .explorer-select-wrap { opacity: 1; }
}
.explorer-select {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}
.tile.explorer-item { position: relative; }
.tile.explorer-item.is-selected {
    box-shadow: inset 0 0 0 2px var(--accent);
    background: var(--row-selected);
}
tr.explorer-item.is-selected td { background: var(--row-selected); }
.list-name { position: relative; }
.list-name .explorer-select-wrap {
    position: relative;
    top: auto;
    left: auto;
    flex-shrink: 0;
    margin-right: 6px;
    opacity: 1;
    background: transparent;
}

.explorer-bulk-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 130;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
    background: var(--surface-raised);
    border-top: 1px solid var(--border-strong);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
}
.explorer-bulk-bar.hidden { display: none !important; }
.explorer-bulk-count {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    min-width: 0;
}
.explorer-bulk-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
@media (max-width: 768px) {
    body.has-explorer-bulk .explorer-bulk-bar {
        bottom: calc(56px + env(safe-area-inset-bottom, 0px));
    }
    body.has-explorer-bulk #app main {
        padding-bottom: calc(112px + env(safe-area-inset-bottom, 0px));
    }
}

/* Move / rename modal */
.move-modal-box { max-width: 520px; }
.move-form label { display: block; margin-bottom: 4px; font-size: 12px; color: var(--muted); }
.move-form input[type="text"] {
    width: 100%;
    margin-bottom: 12px;
    padding: 8px 10px;
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    color: var(--text);
}
.move-modal-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}
.move-modal-box > .secondary#move-modal-close { margin-top: 12px; }
.move-picker {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--input-bg);
    overflow: hidden;
    margin-bottom: 12px;
}
.move-picker-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    background: var(--surface, var(--input-bg));
}
.move-picker-up {
    flex-shrink: 0;
    min-width: 34px;
    padding: 4px 8px;
}
.move-picker-up:disabled { opacity: 0.45; cursor: not-allowed; }
.move-picker-breadcrumb {
    display: flex;
    align-items: center;
    gap: 2px;
    min-width: 0;
    overflow-x: auto;
    font-size: 12px;
    white-space: nowrap;
}
.move-picker-breadcrumb a {
    color: var(--link, var(--accent));
    text-decoration: none;
    padding: 2px 4px;
    border-radius: 4px;
}
.move-picker-breadcrumb a:hover { background: color-mix(in srgb, var(--text) 8%, transparent); }
.move-picker-breadcrumb .path-sep { color: var(--muted); user-select: none; }
.move-picker-list {
    max-height: min(280px, 42vh);
    overflow-y: auto;
    padding: 4px;
}
.move-picker-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--text);
    text-align: left;
    cursor: pointer;
}
.move-picker-item:hover:not(:disabled) {
    background: color-mix(in srgb, var(--text) 6%, transparent);
}
.move-picker-item.is-selected {
    border-color: var(--accent, #4a90d9);
    background: color-mix(in srgb, var(--accent, #4a90d9) 12%, transparent);
}
.move-picker-item:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.move-picker-icon { flex-shrink: 0; font-size: 16px; line-height: 1; }
.move-picker-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.move-picker-path {
    flex-shrink: 0;
    font-size: 11px;
    color: var(--muted);
    font-family: ui-monospace, monospace;
}
.move-picker-loading,
.move-picker-empty {
    padding: 16px 10px;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
}
.move-picker-hint {
    margin: 0;
    padding: 6px 10px 8px;
    font-size: 12px;
    color: var(--warn, #b8860b);
    border-top: 1px solid var(--border);
}
.move-picker-hint.hidden { display: none; }

/* Viewer pinch + PDF */
.viewer-image-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    transform-origin: center center;
    touch-action: none;
}
.viewer-image-wrap.is-pannable {
    will-change: transform;
}
.viewer-image-wrap.is-pannable { cursor: grab; }
.viewer-image-wrap.is-pannable.is-dragging { cursor: grabbing; }
.viewer-body.viewer-body--zoomed { overflow: hidden; }
.viewer-zoom-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex-shrink: 0;
    width: 100%;
    min-height: 32px;
}
.viewer-zoom-controls.hidden {
    visibility: hidden;
    pointer-events: none;
}
.viewer-zoom-level {
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    min-width: 3.2em;
    text-align: center;
    color: var(--muted);
}
.viewer-zoom-btn {
    min-width: 32px;
    padding: 5px 8px;
    line-height: 1;
}
.viewer-zoom-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.viewer-image-wrap.hidden { display: none !important; }
.viewer-pdf {
    width: 100%;
    height: 100%;
    min-height: 0;
    max-height: 100%;
    border: none;
    background: var(--media-bg);
}
.viewer-pdf.hidden { display: none !important; }

@media (prefers-reduced-motion: no-preference) {
    ::view-transition-old(root),
    ::view-transition-new(root) {
        animation-duration: 0.22s;
    }
}

.explorer-drag-band {
    position: absolute;
    border: 1px solid var(--accent);
    background: color-mix(in srgb, var(--accent) 18%, transparent);
    pointer-events: none;
    z-index: 5;
}
.explorer-drag-band.hidden { display: none !important; }
#view-grid { position: relative; }

.viewer-audio {
    width: min(96%, 520px);
    margin: 12px auto;
}

.pwa-install-banner,
.pwa-offline-bar {
    position: fixed;
    left: 0;
    right: 0;
    z-index: 10050;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px calc(10px + env(safe-area-inset-top, 0px));
    background: var(--surface-raised);
    border-bottom: 1px solid var(--border-strong);
    font-size: 13px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}
.pwa-install-banner { top: 0; }
.pwa-offline-bar {
    top: 0;
    background: var(--alert-bg);
    border-color: var(--alert-border);
    justify-content: center;
}
.pwa-install-banner.hidden,
.pwa-offline-bar.hidden { display: none !important; }
.pwa-install-text { flex: 1; }
body.is-offline .upload-panel { border-color: var(--alert-border); }

#prompt-modal input { width: 100%; margin-top: 6px; }
