* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --orange: #ff6b35;
    --orange-light: #ff8c42;
    --orange-soft: #fff5f0;
    --page-bg: #e8ebf0;
    --surface: #f4f5f7;
    --border: #d5dae1;
    --text-muted: #5f6368;
    --radius: 10px;
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-hover: 0 8px 24px rgba(255, 107, 53, 0.12);
    --shadow-panel: 0 10px 40px rgba(0, 0, 0, 0.07);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--page-bg);
    min-height: 100vh;
    padding: 20px 16px 40px;
    color: #202124;
}

.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* Password gate */
.gate {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}

.gate.hidden {
    display: none !important;
}

.gate-panel {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-radius: 14px;
    box-shadow: var(--shadow-panel);
    border: 1px solid var(--border);
    overflow: hidden;
    text-align: center;
}

.gate-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: white;
    padding: 28px 24px 8px;
    background: linear-gradient(135deg, var(--orange) 0%, var(--orange-light) 100%);
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.gate-title .accent {
    font-weight: 800;
    background: linear-gradient(90deg, #fff5f0, #ffffff, #fff5f0);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmer 5s linear infinite;
}

.gate-subtitle {
    padding: 0 24px 20px;
    margin-top: -4px;
    background: linear-gradient(135deg, var(--orange) 0%, var(--orange-light) 100%);
    color: rgba(255, 255, 255, 0.92);
    font-size: 0.9em;
}

.gate-form {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    text-align: left;
}

.gate-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1em;
    background: var(--surface);
}

.gate-input:focus {
    outline: none;
    border-color: var(--orange-light);
    box-shadow: 0 0 0 3px rgba(255, 140, 66, 0.2);
    background: #fff;
}

.gate-remember-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88em;
    color: var(--text-muted);
    cursor: pointer;
}

.gate-remember-label input {
    width: 16px;
    height: 16px;
    accent-color: var(--orange);
}

.gate-error {
    min-height: 1.2em;
    font-size: 0.85em;
    color: #c0392b;
}

.gate-submit {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--orange), var(--orange-light));
    color: white;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.2s;
}

.gate-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(255, 107, 53, 0.4);
}

.logout-btn {
    padding: 6px 12px;
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.12);
    color: white;
    font-size: 0.78em;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

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

.container {
    max-width: 1360px;
    margin: 0 auto;
    background: #fff;
    border-radius: 14px;
    box-shadow: var(--shadow-panel);
    border: 1px solid var(--border);
    overflow: hidden;
}

.app-header {
    position: relative;
    background: linear-gradient(135deg, var(--orange) 0%, var(--orange-light) 100%);
    color: white;
    padding: 18px 48px 16px 32px;
    text-align: center;
}

.app-header .logout-btn {
    position: absolute;
    top: 14px;
    right: 16px;
    margin: 0;
}

header,
.app-header {
    background: linear-gradient(135deg, var(--orange) 0%, var(--orange-light) 100%);
    color: white;
}

header h1,
.app-header h1 {
    font-size: 1.65rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

header .accent {
    font-weight: 800;
    background: linear-gradient(90deg, #fff5f0, #ffffff, #fff5f0);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmer 5s linear infinite;
}

@keyframes shimmer {
    0% { background-position: 0% 50%; }
    100% { background-position: 200% 50%; }
}

.subtitle {
    margin-top: 6px;
    opacity: 0.95;
    font-size: 0.92em;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 6px 10px;
}

.domain-link a {
    color: #fff;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
    opacity: 0.95;
}

.domain-link a:hover {
    opacity: 1;
}

.stats-bar {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    font-size: 0.78em;
}

.stat-chip {
    background: rgba(255, 255, 255, 0.28);
    padding: 4px 10px;
    border-radius: 14px;
    font-weight: 500;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.stat-chip-muted {
    background: rgba(0, 0, 0, 0.12);
    border-color: rgba(255, 255, 255, 0.15);
    font-weight: 400;
}

main {
    padding: 0 0 28px;
}

.toolbar-sticky {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 14px 24px 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
}

.toolbar {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toolbar-row {
    display: flex;
    align-items: stretch;
    gap: 10px;
}

.toolbar-actions {
    display: flex;
    align-items: stretch;
    gap: 10px;
    flex-shrink: 0;
}

.filters-scroll {
    flex: 1;
    min-width: 0;
    position: relative;
    overflow: hidden;
}

.filters-scroll::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 4px;
    width: 28px;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.98));
    pointer-events: none;
}

.sort-wrap {
    flex-shrink: 0;
}

.sort-select {
    min-height: 32px;
    padding: 0 28px 0 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background-color: #fff;
    font-size: 0.82em;
    color: #333;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235f6368' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

.sort-select:focus {
    outline: none;
    border-color: var(--orange-light);
    box-shadow: 0 0 0 3px rgba(255, 140, 66, 0.2);
}

.view-toggle {
    display: flex;
    flex-shrink: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
}

.view-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 32px;
    padding: 0 12px;
    border: none;
    background: transparent;
    font-size: 0.8em;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    white-space: nowrap;
}

.view-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.view-btn:hover {
    background: #fff8f4;
    color: #333;
}

.view-btn.active {
    background: linear-gradient(135deg, var(--orange), var(--orange-light));
    color: white;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.view-btn:focus-visible {
    outline: 2px solid var(--orange-light);
    outline-offset: 1px;
    z-index: 1;
}

.view-btn + .view-btn {
    border-left: 1px solid var(--border);
}

.view-btn.active + .view-btn,
.view-btn + .view-btn.active {
    border-left-color: transparent;
}

.search-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 14px;
    color: #9aa0a6;
    font-size: 1.1em;
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 11px 40px 11px 38px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95em;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: var(--orange-light);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(255, 140, 66, 0.2);
}

.search-input::placeholder {
    color: #9aa0a6;
}

.search-clear {
    position: absolute;
    right: 8px;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: #e8eaed;
    color: #5f6368;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s;
}

.search-clear:hover {
    background: #dadce0;
}

.search-clear.hidden {
    display: none;
}

.category-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.category-tabs::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: #fff;
    font-size: 0.82em;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.tab-btn:hover {
    border-color: var(--orange-light);
    background: #fff8f4;
}

.tab-btn.active {
    background: linear-gradient(135deg, var(--orange), var(--orange-light));
    color: white;
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(255, 107, 53, 0.35);
}

.tab-btn .count {
    margin-left: 0.35em;
    opacity: 0.9;
    font-size: 0.9em;
}

.status {
    margin-top: 4px;
    padding-top: 10px;
    border-top: 1px solid #eceef1;
    color: var(--text-muted);
    font-size: 0.8em;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.status.error {
    color: #c0392b;
}

.asset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 18px;
    padding: 20px 24px 8px;
}

.asset-grid.hidden {
    display: none;
}

.asset-card {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-card);
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.asset-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-hover);
    border-color: rgba(255, 140, 66, 0.35);
}

.asset-card:focus-within {
    border-color: rgba(255, 140, 66, 0.45);
    box-shadow: var(--shadow-hover);
}

.asset-card.hidden {
    display: none;
}

.card-media {
    position: relative;
}

.asset-card-image .thumb-wrap {
    display: block;
    position: relative;
    width: 100%;
    /* 16:9 matches most phone screenshots; contain shows full frame inside */
    aspect-ratio: 16 / 9;
    border: none;
    padding: 0;
    cursor: pointer;
    background: #e8eaed;
    overflow: hidden;
}

.asset-card-image .thumb {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    transition: opacity 0.2s;
}

.asset-card-image .thumb.thumb--loading {
    opacity: 0;
}

.asset-card-image .thumb-wrap:has(.thumb--loading) {
    background: linear-gradient(110deg, #e8eaed 8%, #f4f5f7 18%, #e8eaed 33%);
    background-size: 200% 100%;
    animation: thumb-shimmer 1.2s ease-in-out infinite;
}

@keyframes thumb-shimmer {
    to {
        background-position: -200% 0;
    }
}

.asset-card-image .thumb.thumb--error {
    opacity: 0;
}

.thumb-wrap:has(.thumb--error)::before {
    content: '🖼';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: #e8eaed;
    pointer-events: none;
}

.asset-card-image:hover .thumb:not(.thumb--error) {
    opacity: 0.92;
}

/* Image + file cards: overlay actions on media; show on hover (comfortable + compact) */
.asset-card-image .card-actions--inline,
.asset-card-file .card-actions--inline {
    display: none;
}

.asset-card-image .card-actions.card-actions--overlay,
.asset-card-file .card-actions.card-actions--overlay {
    display: flex;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0;
    padding: 28px 10px 12px;
    gap: 8px;
    justify-content: center;
    align-items: flex-end;
    background: linear-gradient(to top, rgba(15, 20, 30, 0.72) 0%, rgba(15, 20, 30, 0.28) 50%, transparent 100%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
    z-index: 2;
}

.asset-card-image .card-actions--overlay .icon-btn,
.asset-card-file .card-actions--overlay .icon-btn {
    background: rgba(255, 255, 255, 0.94);
    color: #3c4043;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
}

.asset-card-image .card-actions--overlay .icon-btn:hover,
.asset-card-file .card-actions--overlay .icon-btn:hover {
    background: #fff;
    color: var(--orange);
    transform: scale(1.05);
}

.asset-card-image .card-actions--overlay .icon-btn.copied,
.asset-card-file .card-actions--overlay .icon-btn.copied {
    background: #34a853;
    color: #fff;
}

.asset-card-image .card-media:hover .card-actions--overlay,
.asset-card-image .card-media:focus-within .card-actions--overlay,
.asset-card-file .card-media:hover .card-actions--overlay,
.asset-card-file .card-media:focus-within .card-actions--overlay {
    opacity: 1;
    pointer-events: auto;
}

/* Data file preview panel */
.card-media--file .file-preview {
    width: 100%;
    aspect-ratio: 16 / 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(145deg, #f1f3f4, #e8eaed);
    transition: filter 0.2s;
}

.asset-card-file:hover .file-preview {
    filter: brightness(0.97);
}

.file-preview-ext {
    font-size: 0.8em;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: #5f6368;
}

.file-preview-icon {
    font-size: 1.85rem;
    line-height: 1;
    opacity: 0.88;
}

.file-preview[data-ext=".json"] {
    background: linear-gradient(145deg, #e8f4fc, #c6dafc);
}

.file-preview[data-ext=".json"] .file-preview-ext {
    color: #1a73e8;
}

.file-preview[data-ext=".csv"] {
    background: linear-gradient(145deg, #e6f4ea, #c8e6c9);
}

.file-preview[data-ext=".csv"] .file-preview-ext {
    color: #137333;
}

.file-preview[data-ext=".apk"] {
    background: linear-gradient(145deg, #f3e8fd, #e1bee7);
}

.file-preview[data-ext=".apk"] .file-preview-ext {
    color: #7b1fa2;
}

.file-preview[data-ext=".txt"],
.file-preview[data-ext=".xml"] {
    background: linear-gradient(145deg, #fafafa, #eeeeee);
}

.file-preview[data-cat="css"] {
    background: linear-gradient(145deg, #f3e8fd, #e1bee7);
}

.file-preview[data-cat="css"] .file-preview-ext {
    color: #7b1fa2;
}

.file-preview[data-cat="js"] {
    background: linear-gradient(145deg, #fef7e0, #ffe082);
}

.file-preview[data-cat="js"] .file-preview-ext {
    color: #e37400;
}

.file-preview[data-cat="md"] {
    background: linear-gradient(145deg, #e6f4ea, #c8e6c9);
}

.file-preview[data-cat="md"] .file-preview-ext {
    color: #137333;
}

.file-preview[data-cat="other"] {
    background: linear-gradient(145deg, #f1f3f4, #e8eaed);
}

.file-preview[data-cat="other"] .file-preview-ext {
    color: #5f6368;
}

.card-media-row {
    display: flex;
    align-items: stretch;
    gap: 0;
}

.asset-card-file .card-media-row {
    padding: 14px 14px 0;
}

.file-icon {
    width: 72px;
    height: 72px;
    min-width: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #f1f3f4, #e8eaed);
    border-radius: var(--radius);
    font-size: 2rem;
}

.card-body {
    padding: 12px 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.card-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.card-name {
    font-weight: 600;
    color: #202124;
    font-size: 0.92em;
    line-height: 1.35;
    word-break: break-word;
}

.asset-grid:not(.view-compact):not(.view-masonry) .card-name {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.category-badge {
    flex-shrink: 0;
    align-self: center;
    font-size: 0.68em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 3px 8px;
    border-radius: 4px;
    background: #fff0e8;
    color: var(--orange);
}

.category-badge[data-cat="data"] { background: #e8f4fc; color: #1a73e8; }
.category-badge[data-cat="css"] { background: #f3e8fd; color: #7b1fa2; }
.category-badge[data-cat="js"] { background: #fef7e0; color: #e37400; }
.category-badge[data-cat="md"] { background: #e6f4ea; color: #137333; }

.card-meta {
    font-size: 0.78em;
    color: var(--text-muted);
}

.card-path {
    display: block;
    padding: 5px 9px;
    background: #f8f9fa;
    border: 1px solid #e8eaed;
    border-radius: 6px;
    font-family: ui-monospace, 'SF Mono', Monaco, monospace;
    font-size: 0.7em;
    color: #5f6368;
    line-height: 1.35;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.alt-chip {
    font-size: 0.72em;
}

.alt-chip a {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    background: #e8f0fe;
    color: #1967d2;
    text-decoration: none;
    font-weight: 500;
}

.alt-chip a:hover {
    background: #d2e3fc;
    text-decoration: none;
}

.card-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: auto;
    padding-top: 4px;
}

.icon-btn {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    padding: 7px;
    background: var(--orange-light);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.15s;
}

.icon-btn:hover {
    background: var(--orange);
    transform: scale(1.06);
}

.icon-btn.copied {
    background: #34a853;
}

.icon-btn svg {
    width: 15px;
    height: 15px;
}

.empty-state {
    text-align: center;
    padding: 56px 24px;
    color: #9aa0a6;
    font-size: 1em;
}

.empty-state.hidden {
    display: none;
}

.scroll-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--orange), var(--orange-light));
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(255, 107, 53, 0.45);
    z-index: 60;
    transition: opacity 0.2s, transform 0.2s;
}

.scroll-top:hover {
    transform: scale(1.08);
}

.scroll-top.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Lightbox */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(15, 20, 30, 0.92);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px 24px;
}

.lightbox.hidden {
    display: none;
}

.lightbox img {
    max-width: min(95vw, 1200px);
    max-height: min(85vh, 900px);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

.lightbox-caption {
    margin-top: 14px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.95em;
    max-width: 90vw;
    text-align: center;
    word-break: break-word;
}

.lightbox-close {
    position: absolute;
    top: 16px;
    right: 20px;
    background: rgba(255, 255, 255, 0.12);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.6rem;
    cursor: pointer;
    line-height: 1;
    transition: background 0.2s;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.22);
}

.lightbox-actions {
    margin-top: 18px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.lightbox-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    background: var(--orange-light);
    color: white;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
}

.lightbox-btn:hover {
    background: var(--orange);
}

.lightbox-btn-outline {
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.5);
}

.lightbox-btn-outline:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: white;
}

.lightbox-btn.copied {
    background: #34a853;
}

@media (min-width: 900px) {
    .asset-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
}

/* Compact view — denser grid, smaller cards */
.asset-grid.view-compact {
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
    gap: 10px;
    padding: 14px 20px 8px;
}

@media (min-width: 900px) {
    .asset-grid.view-compact {
        grid-template-columns: repeat(auto-fill, minmax(156px, 1fr));
    }
}

@media (min-width: 1280px) {
    .asset-grid.view-compact {
        grid-template-columns: repeat(auto-fill, minmax(152px, 1fr));
    }
}

.asset-grid.view-compact .asset-card {
    border-radius: 8px;
    min-height: 0;
}

.asset-grid.view-compact .asset-card-image,
.asset-grid.view-compact .asset-card-file {
    display: flex;
    flex-direction: column;
}

.asset-grid.view-compact .asset-card:hover,
.asset-grid.view-compact .asset-card:focus-within {
    border-color: rgba(255, 140, 66, 0.55);
    box-shadow: 0 2px 12px rgba(255, 107, 53, 0.15);
}

.asset-grid.view-compact .asset-card-image .thumb-wrap {
    aspect-ratio: 1 / 1;
}

.asset-grid.view-compact .asset-card-file .file-preview {
    aspect-ratio: 1 / 1;
    gap: 4px;
}

.asset-grid.view-compact .asset-card-file .file-preview-ext {
    font-size: 0.68em;
}

.asset-grid.view-compact .asset-card-file .file-preview-icon {
    font-size: 1.5rem;
}

.asset-grid.view-compact .card-body {
    padding: 6px 8px 8px;
    gap: 4px;
    flex: 1;
    min-height: 3.2em;
}

.asset-grid.view-compact .card-header-row {
    gap: 0;
}

.asset-grid.view-compact .card-name {
    font-size: 0.75em;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    width: 100%;
}

.asset-grid.view-compact .card-meta,
.asset-grid.view-compact .card-path,
.asset-grid.view-compact .alt-chip,
.asset-grid.view-compact .category-badge {
    display: none;
}

/* Compact: smaller overlay buttons on image + file media */
.asset-grid.view-compact .asset-card-image .card-actions--overlay,
.asset-grid.view-compact .asset-card-file .card-actions--overlay {
    padding: 20px 4px 6px;
    gap: 4px;
}

.asset-grid.view-compact .asset-card-image .card-actions--overlay .icon-btn,
.asset-grid.view-compact .asset-card-file .card-actions--overlay .icon-btn {
    width: 26px;
    height: 26px;
    padding: 4px;
    border-radius: 5px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.asset-grid.view-compact .card-actions--overlay .icon-btn svg {
    width: 12px;
    height: 12px;
}

/* Masonry — JS shortest-column layout; intrinsic image heights */
.asset-grid.view-masonry {
    display: block;
    position: relative;
    padding: 20px 20px 12px;
}

.asset-grid.view-masonry .asset-card {
    margin: 0;
    border-radius: 12px;
}

.asset-grid.view-masonry .asset-card:hover {
    transform: translateY(-2px);
    z-index: 2;
    box-shadow: var(--shadow-hover);
}

.asset-grid.view-masonry .asset-card-image .thumb-wrap {
    aspect-ratio: auto;
    min-height: 80px;
}

.asset-grid.view-masonry .asset-card-image .thumb {
    display: block;
    width: 100%;
    height: auto;
    max-height: min(55vh, 520px);
    object-fit: contain;
}

.asset-grid.view-masonry .asset-card-file .file-preview {
    aspect-ratio: 4 / 3;
    min-height: 100px;
}

.asset-grid.view-masonry .card-body {
    padding: 8px 10px 10px;
}

.asset-grid.view-masonry .card-name {
    font-size: 0.8125rem;
    -webkit-line-clamp: 2;
}

.asset-grid.view-masonry .card-meta,
.asset-grid.view-masonry .card-path {
    font-size: 0.6875rem;
}

.asset-grid.view-masonry .card-path {
    -webkit-line-clamp: 1;
}

.masonry-measure {
    position: absolute;
    left: -9999px;
    top: 0;
    visibility: hidden;
    pointer-events: none;
    width: 260px;
}

@media (max-width: 960px) {
    .toolbar-row {
        flex-wrap: wrap;
    }

    .filters-scroll {
        flex: 1 1 100%;
        width: 100%;
    }

    .toolbar-actions {
        flex: 1 1 100%;
        width: 100%;
    }

    .sort-wrap {
        flex: 1;
        min-width: 0;
    }

    .sort-select {
        width: 100%;
    }

    .view-toggle {
        flex: 1;
        min-width: 0;
    }
}

@media (max-width: 720px) {
    .view-btn-label {
        display: none;
    }

    .view-btn {
        padding: 0 10px;
    }
}

@media (max-width: 600px) {
    header {
        padding: 22px 18px 18px;
    }

    .toolbar-sticky {
        padding: 12px 16px 10px;
    }

    .asset-grid {
        grid-template-columns: 1fr;
        padding: 16px;
    }

    .asset-grid.view-compact {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    }

    .toolbar-actions {
        flex-direction: column;
    }

    .view-toggle {
        width: 100%;
        justify-content: stretch;
    }

    .view-toggle .view-btn {
        flex: 1;
        justify-content: center;
    }
}
