/* WS-C1: base (theme tokens and reset) */
:root {
    --bg-color: #0d0d0d;
    --sidebar-bg: #151515;
    --text-color: #ffffff;
    --text-muted: #888888;
    --accent: #ff2a5f;
    --hover-bg: #222222;
    --border: #333333;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body, html {
    width: 100%; height: 100vh;
    background: var(--bg-color);
    font-family: 'Inter', -apple-system, sans-serif;
    color: var(--text-color);
    overflow: hidden;
}
body.swiper-open,
html.swiper-open {
    overflow: hidden;
}

/*
WS-C1 split map:
base -> variables, reset, document chrome
layout -> app shell, sidebar, top nav, grid container
components -> buttons, chips, cards, pills, modals
features -> swiper, settings, lora picker, selection overlays
mobile -> responsive overrides in the media queries below
*/

/* WS-C1: layout (app shell) */
.app-container {
    display: flex; height: 100vh; width: 100vw;
}

/* WS-C1: layout (sidebar) */
.sidebar {
    width: 320px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
}
.sidebar-header {
    padding: 20px; border-bottom: 1px solid var(--border);
}
.sidebar-header h2 { font-size: 1.2rem; font-weight: 600; letter-spacing: 0.5px; }

.folder-list {
    flex: 1; overflow-y: auto;
    padding: 10px;
}
.folder-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 8px 6px;
    color: #8d8d8d;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.folder-section-header span:last-child {
    color: #666;
    font-size: 0.68rem;
}
.folder-item {
    padding: 15px; border-radius: 8px; cursor: pointer;
    margin-bottom: 8px; border: 1px solid transparent;
    transition: all 0.2s;
}
.folder-item:hover { background: var(--hover-bg); }
.folder-item.active {
    background: rgba(255, 42, 95, 0.1);
    border-color: rgba(255, 42, 95, 0.3);
}
.folder-item.virtual-folder {
    background: rgba(255,255,255,0.02);
    border-color: rgba(255,255,255,0.04);
}
.folder-item.virtual-folder strong {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.folder-item-badge {
    display: inline-flex;
    align-items: center;
    min-height: 20px;
    padding: 0 8px;
    border-radius: 999px;
    background: rgba(255, 42, 95, 0.12);
    color: #ff8faa;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.folder-item strong { display: block; font-size: 0.9rem; margin-bottom: 5px; color:#e0e0e0;}
.folder-item small { font-size: 0.75rem; color: var(--text-muted); display:block;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-classifier {
    padding: 15px;
    border-top: 1px solid var(--border);
    background: rgba(255,255,255,0.02);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.sidebar-classifier h3 {
    font-size: 0.85rem;
    color: #fff;
}
.sidebar-classifier-status {
    color: #999;
    font-size: 0.75rem;
    line-height: 1.45;
    min-height: 32px;
}

/* WS-C1: layout (main content and mobile chrome) */
.main-content {
    flex: 1; display: flex; flex-direction: column;
    background: var(--bg-color);
}
.top-nav {
    height: 80px; padding: 0 30px; border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
}
.top-nav-primary {
    display: contents;
}
.nav-left h1 { font-size: 1.5rem; font-weight: 800; margin-bottom: 4px; }
.nav-left .subtitle { font-size: 0.85rem; color: var(--text-muted); 
    max-width: 600px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.top-stats {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}
.top-stat {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.04);
    color: #d8d8d8;
    font-size: 0.78rem;
    font-weight: 600;
}

.nav-right { display: flex; align-items: center; gap: 15px; }
.mobile-menu-toggle,
.mobile-menu-overlay,
.mobile-menu-actions,
.mobile-quick-filters,
.mobile-only-btn,
.mobile-swiper-sheet {
    display: none;
}
.mobile-menu-toggle {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.03);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
}
.mobile-menu-toggle span {
    width: 18px;
    height: 2px;
    border-radius: 999px;
    background: #fff;
    display: block;
}
.mobile-menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.52);
    z-index: 119;
}
.mobile-quick-filters {
    gap: 8px;
    padding: 10px 12px 0;
    overflow-x: auto;
    white-space: nowrap;
}
.mobile-quick-filters .chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.03);
    color: #d6d6d6;
    font-size: 0.82rem;
    font-weight: 600;
}
.mobile-quick-filters .chip.active {
    border-color: rgba(255, 42, 95, 0.45);
    background: rgba(255, 42, 95, 0.14);
    color: #fff;
}
.mobile-swiper-sheet {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1003;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
    background: rgba(12,12,12,0.96);
    backdrop-filter: blur(18px);
    padding: 10px 16px calc(18px + env(safe-area-inset-bottom, 0px));
    transform: translateY(calc(100% - 44px));
    transition: transform 0.24s ease;
}
.mobile-swiper-sheet.open {
    transform: translateY(0);
}
.mobile-swiper-sheet-handle {
    width: 42px;
    height: 4px;
    border-radius: 999px;
    background: rgba(255,255,255,0.22);
    margin: 0 auto 12px;
}
.mobile-swiper-sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.mobile-swiper-meta-content {
    max-height: 24vh;
    overflow-y: auto;
    color: #d2d2d2;
    font-size: 0.8rem;
    line-height: 1.45;
}
.mobile-swiper-sheet-actions {
    display: grid;
    gap: 10px;
    margin-top: 12px;
}
.mobile-swiper-sheet textarea {
    width: 100%;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #171717;
    color: #fff;
    font-size: 0.86rem;
    resize: none;
}
.mobile-lipsync-status {
    font-size: 0.78rem;
    text-align: center;
    color: #a9a9a9;
}
.status-pill {
    background: var(--sidebar-bg); border: 1px solid var(--border);
    padding: 6px 12px; border-radius: 20px; display: flex; align-items: center; gap: 8px;
    font-size: 0.8rem; font-weight: 600;
}
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot.off { background: #555; }
.dot.on { background: #00e676; box-shadow: 0 0 10px #00e676; animation: pulse 1.5s infinite; }

.btn {
    padding: 8px 16px; border-radius: 6px; font-weight: 600; font-size: 0.85rem;
    cursor: pointer; transition: 0.2s; border: none;
}
.btn.primary { background: var(--accent); color: white; }
.btn.outline { background: transparent; border: 1px solid var(--text-muted); color: var(--text-color); }
.btn.outline:hover { border-color: var(--text-color); }
.icon-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; }
.icon-btn:hover { color: white; }

/* WS-C1: features (gallery grid and selection state) */
.grid-container {
    flex: 1; padding: 30px; overflow-y: auto;
    display: grid;
    /* Responsive Grid: min 200px columns */
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    grid-auto-rows: max-content;
    gap: 20px;
    padding-bottom: max(40px, calc(30px + env(safe-area-inset-bottom, 0px)));
}
.grid-item {
    position: relative;
    padding-bottom: 177.78%; /* 16:9 vertical portrait */
    background: var(--sidebar-bg); border-radius: 8px; overflow: hidden;
    cursor: pointer; border: 1px solid var(--border); transition: transform 0.2s, box-shadow 0.2s;
    user-select: none; -webkit-user-select: none;
}
.grid-item:hover { transform: translateY(-4px); box-shadow: 0 10px 20px rgba(0,0,0,0.5); }
.grid-item img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.grid-tag-overlay {
    position: absolute;
    left: 10px;
    bottom: 10px;
    z-index: 4;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-width: calc(100% - 20px);
    pointer-events: none;
}
.image-tag-chip {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 9px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.66);
    border: 1px solid rgba(255,255,255,0.12);
    color: #f4f4f4;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 8px 18px rgba(0,0,0,0.18);
}
.image-tag-chip.flag {
    border-color: rgba(255, 42, 95, 0.35);
    background: rgba(255, 42, 95, 0.22);
}
.image-tag-chip.subtle {
    color: #cfcfcf;
}
.empty-state { grid-column: 1 / -1; color: var(--text-muted); text-align: center; margin-top: 50px;}

/* Selection Mode */
.grid-item .select-layer {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.1); display: none; z-index: 10;
}
.grid-item.selected .select-layer { display: block; background: rgba(0,0,0,0.3); border: 2px solid var(--accent); border-radius: 8px;}
.grid-item .check {
    position: absolute; top: 10px; right: 10px;
    width: 24px; height: 24px; border-radius: 50%; border: 2px solid #fff;
    display: none; justify-content: center; align-items: center; font-size: 14px;
    background: rgba(0,0,0,0.4);
}
#grid-container.selection-mode .grid-item .check { display: flex; }
.grid-item.selected .check { background: var(--accent); border-color: var(--accent); color: white; }

/* WS-C1: features (floating actions and swiper modal) */
.floating-action-bar {
    position: fixed; bottom: -100px; left: 50%; transform: translateX(-50%);
    background: #1a1a1a; padding: 15px 30px; border-radius: 30px; border: 1px solid var(--border);
    display: flex; align-items: center; gap: 20px; z-index: 900;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8); transition: 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.floating-action-bar.visible {
    bottom: calc(40px + env(safe-area-inset-bottom, 0px));
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}
.floating-action-bar strong { color: #fff; }/* Fullscreen Swiper Modal */
.swiper-modal {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.95); backdrop-filter: blur(10px);
    z-index: 1000; display: flex; flex-direction: column;
}
.swiper-body {
    flex: 1;
    min-height: 0;
    display: flex;
}
.swiper-close {
    position: absolute; top: 20px; left: 30px; z-index: 1010;
    background: none; border: none; color: #fff; font-size: 1.5rem; cursor: pointer; opacity: 0.6;
}
.swiper-close:hover { opacity: 1; }
.swiper-delete-btn {
    border-color: rgba(255, 42, 95, 0.4);
    color: #ff90ab;
}
.swiper-delete-btn:hover {
    border-color: var(--accent);
    color: #fff;
}

.swiper-layout {
    flex: 1; display: flex; align-items: center; justify-content: center;
    position: relative; overflow: hidden; overscroll-behavior: contain;
    min-width: 0;
    cursor: default;
}
.swiper-layout.zoomable {
    cursor: grab;
}
.swiper-layout.dragging {
    cursor: grabbing;
}
.swiper-nav {
    position: absolute; top: 50%; transform: translateY(-50%);
    background: rgba(255,255,255,0.1); border: none; color: white;
    width: 50px; height: 50px; border-radius: 50%; font-size: 1.5rem;
    cursor: pointer; z-index: 1010; transition: 0.2s;
}
.swiper-nav:hover { background: rgba(255,255,255,0.3); }
.swiper-nav.prev { left: 40px; }
.swiper-nav.next { right: 40px; }

.swiper-track {
    display: flex; height: 100%; height: 90vh; width: 100%;
    transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}
.swiper-slide {
    min-width: 100%; display: flex; justify-content: center; align-items: center;
    padding: 0 100px; /* Space for arrows */
}
/* This is the magic for Uncropped Full Screen! */
.swiper-slide img {
    max-width: 100%; max-height: 100%;
    object-fit: contain; box-shadow: 0 10px 40px rgba(0,0,0,0.8);
    transform-origin: center center;
    transition: transform 0.18s ease-out;
    will-change: transform;
    -webkit-user-drag: none;
    user-select: none;
}
.swiper-sidebar {
    width: 360px;
    flex: 0 0 360px;
    border-left: 1px solid rgba(255,255,255,0.08);
    background: rgba(10,10,10,0.94);
    padding: 84px 18px 18px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.swiper-side-card {
    background: rgba(18,18,18,0.9);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 18px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.swiper-side-title {
    margin: 0;
    color: #ff2a5f;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.06em;
}
.swiper-meta-content {
    font-size: 0.8rem;
    color: #ccc;
    line-height: 1.5;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.swiper-tag-overlay {
    position: absolute;
    left: 22px;
    bottom: 22px;
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-width: min(72%, 560px);
    pointer-events: none;
}
.swiper-tag-overlay .image-tag-chip {
    min-height: 30px;
    padding: 0 12px;
    font-size: 0.78rem;
}
.review-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.review-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.03);
    color: #d5d5d5;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: 0.18s ease;
}
.review-chip.active {
    border-color: rgba(255, 42, 95, 0.45);
    background: rgba(255, 42, 95, 0.18);
    color: #fff;
}
.review-summary {
    color: #bcbcbc;
    font-size: 0.78rem;
    line-height: 1.5;
}
.swiper-review-card textarea {
    width: 100%;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #171717;
    color: #fff;
    font-size: 0.84rem;
    resize: vertical;
}
.swiper-lipsync-card textarea {
    min-height: 120px;
}

.swiper-footer {
    height: 60px; border-top: 1px solid rgba(255,255,255,0.1); display: flex;
    justify-content: space-between; align-items: center; padding: 0 30px;
}

/* WS-C1: components (general modals and settings surfaces) */
.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85); backdrop-filter: blur(5px);
    z-index: 999; display: flex; justify-content: center; align-items: center;
}
.modal-content {
    background: #1a1a1a; padding: 25px; border-radius: 12px;
    width: 85%; max-width: 400px; position: relative; border: 1px solid var(--border);
}
.modal-content h3 { margin-bottom: 15px; font-size: 1.1rem; color: #fff; }
.modal-content label { display: block; font-size: 0.85rem; color: var(--text-muted); margin-top: 15px; margin-bottom: 5px; }
.modal-content input {
    width: 100%; padding: 10px; background: #000; border: 1px solid #333;
    color: #fff; border-radius: 6px; font-size: 1rem;
}
.modal-content input:focus { outline: none; border-color: var(--accent); }
.settings-modal-content {
    width: min(96vw, 1180px);
    max-width: 1180px;
    max-height: min(90vh, 980px);
    background: #141414;
    display: flex;
    flex-direction: column;
    gap: 18px;
    overflow: hidden;
    padding: 26px;
}
.settings-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding-right: 34px;
}
.settings-modal-subtitle {
    color: #9a9a9a;
    font-size: 0.9rem;
    line-height: 1.45;
    max-width: 720px;
}
.settings-cover-row {
    display: flex;
    gap: 18px;
    align-items: center;
    padding: 16px;
    border-radius: 18px;
    border: 1px solid #2b2b2b;
    background: #181818;
}
.settings-cover-preview {
    width: 110px;
    height: 110px;
    background: #222;
    border-radius: 14px;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border);
    flex: 0 0 110px;
}
.settings-cover-meta {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.settings-title-input {
    font-size: 1.25rem !important;
    font-weight: 800 !important;
    border: none !important;
    border-bottom: 1px solid #333 !important;
    background: transparent !important;
    padding: 6px 0 !important;
    border-radius: 0 !important;
}
.settings-cover-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.settings-modal-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.95fr);
    gap: 18px;
    min-height: 0;
    flex: 1;
    overflow: hidden;
}
.settings-main-column,
.settings-side-column {
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 18px;
    overflow-y: auto;
    padding-right: 4px;
}
.settings-panel {
    background: #181818;
    border: 1px solid #2b2b2b;
    border-radius: 18px;
    padding: 18px;
}
.settings-two-col {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
.settings-config-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
.settings-lora-panel {
    min-height: 0;
    flex: 1;
}
.settings-lora-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 260px;
    max-height: none;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 6px;
}
.settings-footer {
    display: flex;
    gap: 12px;
    padding-top: 2px;
    align-items: center;
}
.settings-footer .btn {
    min-height: 42px;
    padding: 0 16px;
}
.settings-footer-top {
    padding-top: 0;
}
.settings-lora-item {
    background: #111;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid #333;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.settings-selected-model {
    display: grid;
    grid-template-columns: 84px minmax(0, 1fr);
    gap: 12px;
    margin-bottom: 12px;
}
.settings-selected-model-cover {
    width: 84px;
    height: 84px;
    border-radius: 14px;
    overflow: hidden;
    background: #141414;
    border: 1px solid #2f2f2f;
}
.settings-selected-model-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.settings-selected-model-cover-empty {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 0.72rem;
}
.settings-selected-model-meta {
    min-width: 0;
}
.settings-selected-model-meta input {
    width: 100%;
}
.settings-lora-head {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
}
.settings-lora-thumb {
    width: 56px;
    height: 56px;
    border-radius: 10px;
    object-fit: cover;
    background: #171717;
    border: 1px solid #303030;
}
.settings-lora-thumb-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 0.68rem;
}
.settings-lora-head-meta {
    min-width: 0;
}
.settings-lora-picked-name {
    font-size: 0.86rem;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.settings-lora-picked-id {
    margin-top: 3px;
    font-size: 0.72rem;
    color: #8c8c8c;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.settings-lora-grid-top,
.settings-lora-grid-bottom {
    display: grid;
    gap: 10px;
}
.settings-lora-grid-top {
    grid-template-columns: minmax(0, 1fr) 92px;
    align-items: end;
}
.settings-lora-grid-bottom {
    grid-template-columns: minmax(0, 1fr) 104px;
}
.settings-lora-label {
    display: block;
    margin-bottom: 4px;
    font-size: 0.76rem;
    color: #8f8f8f;
}
.settings-lora-item input {
    font-size: 0.82rem;
}
.lora-picker-modal-content {
    max-width: 1280px;
    width: min(96vw, 1280px);
    max-height: min(90vh, 920px);
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.lora-picker-header,
.lora-picker-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
}
.lora-picker-search-row {
    display: flex;
    gap: 10px;
    align-items: center;
}
.lora-picker-search-row input {
    min-width: 320px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid #333;
    background: #121212;
    color: #fff;
    font-size: 0.9rem;
}
.lora-picker-tabs {
    display: flex;
    gap: 8px;
}
.lora-picker-tabs .btn.active {
    border-color: #ff2a5f;
    color: #fff;
    background: rgba(255, 42, 95, 0.12);
}
.lora-picker-status {
    color: #9a9a9a;
    font-size: 0.85rem;
}
.lora-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
    overflow-y: auto;
    padding-right: 4px;
    min-height: 320px;
}
.lora-picker-card {
    background: #111;
    border: 1px solid #2a2a2a;
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.lora-picker-card-cover {
    aspect-ratio: 1 / 1;
    min-height: 220px;
    background: #1a1a1a;
    overflow: hidden;
}
.lora-picker-card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.lora-picker-card-body {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.lora-picker-card-title {
    font-weight: 700;
    color: #fff;
    line-height: 1.3;
    min-height: 2.6em;
}
.lora-picker-card-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    color: #9a9a9a;
    font-size: 0.8rem;
}
.lora-picker-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.lora-picker-card-tags span {
    padding: 3px 8px;
    border-radius: 999px;
    background: #1d1d1d;
    border: 1px solid #333;
    color: #c9c9c9;
    font-size: 0.72rem;
}
.lora-picker-card-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}
.lora-picker-card-actions select {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid #333;
    background: #151515;
    color: #fff;
}
.lora-picker-empty {
    padding: 36px 20px;
    text-align: center;
    color: #8f8f8f;
    border: 1px dashed #333;
    border-radius: 16px;
}

@keyframes pulse { 0% { opacity: 0.6; } 50% { opacity: 1; } 100% { opacity: 0.6; } }

/* WS-C1: mobile (responsive overrides) */
@media screen and (max-width: 768px) {
    body, html {
        height: auto;
        min-height: 100vh;
        overflow-x: hidden;
        overflow-y: auto;
    }
    body.mobile-menu-open,
    html.mobile-menu-open {
        overflow: hidden;
    }
    .app-container {
        flex-direction: column;
        width: 100%;
        height: auto;
        min-height: 100vh;
    }
    .main-content {
        order: 1;
        width: 100%;
        min-width: 0;
    }
    .sidebar {
        display: none;
    }
    body.mobile-menu-open .sidebar {
        display: flex;
        position: fixed;
        top: var(--mobile-menu-top, 92px);
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-height: none;
        z-index: 121;
        border-right: none;
        border-top: 1px solid var(--border);
        background: rgba(21,21,21,0.98);
        backdrop-filter: blur(18px);
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
    .sidebar-header {
        padding: 16px 18px;
        position: sticky;
        top: 0;
        z-index: 1;
        background: rgba(21,21,21,0.96);
    }
    .mobile-menu-actions {
        display: block;
        padding: 14px 16px 10px;
        border-bottom: 1px solid var(--border);
    }
    .mobile-menu-actions .nav-right {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
        width: 100%;
    }
    .folder-list {
        display: block;
        gap: 0;
        overflow-x: hidden;
        overflow-y: auto;
        padding: 14px 16px 24px;
        scroll-snap-type: none;
        min-height: 0;
    }
    .folder-item {
        min-width: 0;
        margin-bottom: 8px;
        scroll-snap-align: none;
    }
    .top-nav {
        position: sticky;
        top: 0;
        z-index: 118;
        height: auto;
        padding: max(16px, env(safe-area-inset-top)) 16px 14px;
        align-items: stretch;
        flex-direction: column;
        gap: 0;
        background: rgba(13,13,13,0.96);
        backdrop-filter: blur(14px);
    }
    .top-nav-primary {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 12px;
    }
    .nav-left h1 {
        display: none; /* Hide on mobile in favor of the select dropdown */
    }
    .mobile-portfolio-select {
        display: block !important;
        width: 100%;
        background: rgba(40,40,40,0.95);
        color: #fff;
        border: 1px solid var(--border);
        padding: 10px 14px;
        border-radius: 12px;
        font-size: 1.1rem;
        font-weight: bold;
        margin-bottom: 6px;
        outline: none;
        appearance: none;
        -webkit-appearance: none;
        background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23FFFFFF%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
        background-repeat: no-repeat;
        background-position: right 14px top 50%;
        background-size: 14px auto;
        box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    }
    .nav-left .subtitle {
        max-width: 100%;
        white-space: normal;
        line-height: 1.4;
    }
    .mobile-menu-toggle {
        display: inline-flex;
        flex: 0 0 auto;
        margin-top: 2px;
    }
    .nav-right {
        display: none;
    }
    .mobile-quick-filters {
        display: flex;
    }
    .status-pill {
        justify-content: center;
    }
    .mobile-menu-actions #filter-model,
    .mobile-menu-actions #open-catalog-btn,
    .mobile-menu-actions #toggle-select-mode,
    .mobile-menu-actions #toggle-engine,
    .mobile-menu-actions .status-pill,
    #settings-btn,
    #sync-archive-start,
    #sync-archive-stop {
        width: 100%;
        font-size: 0.9rem;
        min-height: 44px;
    }
    body.mobile-menu-open .mobile-menu-overlay {
        display: block;
    }
    .grid-container {
        padding: 14px 12px max(96px, calc(24px + env(safe-area-inset-bottom, 0px)));
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }
    .grid-item {
        padding-bottom: 0;
        aspect-ratio: 3 / 4;
        border-radius: 12px;
    }
    .grid-item:hover {
        transform: none;
        box-shadow: none;
    }
    .swiper-tag-overlay {
        left: 14px;
        right: 14px;
        bottom: 14px;
        max-width: none;
    }
    .swiper-tag-overlay .image-tag-chip {
        min-height: 28px;
        font-size: 0.74rem;
    }
    .floating-action-bar {
        width: calc(100vw - 24px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
        left: calc(12px + env(safe-area-inset-left, 0px));
        transform: none;
        bottom: -180px;
        border-radius: 18px;
        padding: 14px 14px calc(14px + env(safe-area-inset-bottom, 0px));
        flex-wrap: wrap;
        gap: 12px;
    }
    .floating-action-bar.visible {
        bottom: max(12px, env(safe-area-inset-bottom, 0px));
    }
    .floating-action-bar > * {
        width: 100%;
    }
    .swiper-modal {
        background: rgba(0,0,0,0.98);
    }
    .swiper-body {
        display: block;
    }
    .swiper-close {
        position: absolute;
        top: max(16px, env(safe-area-inset-top));
        right: 16px;
        left: auto;
        font-size: 1.8rem;
        opacity: 0.9;
        z-index: 120;
        transition: opacity 0.3s ease, transform 0.3s ease;
        background: rgba(0,0,0,0.4);
        border-radius: 50%;
        width: 44px;
        height: 44px;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    .swiper-layout {
        flex: 1;
        width: 100vw;
        min-height: 0;
        overflow: hidden;
        align-items: stretch;
        touch-action: none;
    }
    .swiper-track {
        height: 100%;
    }
    .swiper-slide {
        min-width: 100vw;
        height: 100%;
        padding: 0; /* Remove top/bottom padding to make it full screen */
        align-items: center;
        justify-content: center;
        position: relative;
    }
    .swiper-slide img,
    .swiper-slide video {
        width: 100vw;
        height: 100%;
        max-width: 100vw;
        max-height: 100%;
        object-fit: contain;
        box-shadow: none;
        border-radius: 0;
    }
    .swiper-slide img {
        pointer-events: none;
    }
    .swiper-nav {
        display: none;
    }
    .swiper-footer {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 110;
        height: auto;
        min-height: 88px;
        padding: 24px 16px calc(env(safe-area-inset-bottom, 0px) + 12px);
        gap: 12px;
        background: linear-gradient(to top, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.6) 60%, transparent 100%);
        flex-wrap: wrap;
        transition: opacity 0.3s ease, transform 0.3s ease;
    }
    
    /* Immersive Mode rules */
    .swiper-modal.immersive-mode .swiper-close {
        opacity: 0;
        pointer-events: none;
        transform: translateY(-20px);
    }
    .swiper-modal.immersive-mode .swiper-footer {
        opacity: 0;
        pointer-events: none;
        transform: translateY(20px);
    }
    .swiper-modal.immersive-mode .swiper-tag-overlay {
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }
    .mobile-only-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    .swiper-footer .btn {
        flex: 1;
        min-height: 44px;
    }
    .swiper-sidebar {
        display: none;
    }
    #swiper-info-panel,
    #lipsync-panel {
        display: none !important;
    }
    .mobile-swiper-sheet {
        display: block;
    }
    .top-stats {
        gap: 6px;
    }
    .top-stat {
        font-size: 0.74rem;
    }
    .modal {
        align-items: flex-start;
        overflow-y: auto;
        padding: 16px 0;
    }
    .modal-content {
        width: calc(100% - 24px);
        max-width: none;
        padding: 16px;
        margin: 0 auto;
    }
    .settings-modal-content {
        width: calc(100% - 24px);
        max-height: none;
        padding: 18px;
    }
    .settings-modal-grid,
    .settings-two-col,
    .settings-config-grid,
    .settings-footer {
        grid-template-columns: 1fr;
        display: grid;
    }
    .settings-main-column,
    .settings-side-column {
        overflow: visible;
        padding-right: 0;
    }
    .settings-cover-row {
        flex-direction: column;
        align-items: flex-start;
    }
    .settings-cover-preview {
        width: 92px;
        height: 92px;
        flex-basis: 92px;
    }
    .settings-cover-actions {
        width: 100%;
    }
    .settings-cover-actions .btn,
    .settings-footer .btn {
        width: 100%;
    }
    .settings-lora-grid-top {
        grid-template-columns: 1fr;
    }
    .settings-lora-grid-bottom {
        grid-template-columns: 1fr;
    }
    .lora-picker-modal-content {
        width: calc(100% - 24px);
        max-height: none;
    }
    .lora-picker-header,
    .lora-picker-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .lora-picker-search-row {
        flex-direction: column;
        align-items: stretch;
    }
    .lora-picker-search-row input {
        min-width: 0;
        width: 100%;
    }
}
@media screen and (max-width: 480px) {
    .folder-item {
        min-width: 160px;
    }
    .swiper-footer {
        justify-content: space-between;
        padding-top: 10px;
    }
    #swiper-counter {
        width: 100%;
        text-align: left;
    }
    #swiper-download,
    #swiper-delete,
    #swiper-meta-toggle {
        width: 100%;
    }
}
@media screen and (max-width: 932px) and (orientation: landscape) {
    .top-nav {
        padding: max(10px, env(safe-area-inset-top)) 14px 10px;
    }
    .nav-left h1 {
        font-size: 1rem;
    }
    .nav-left .subtitle {
        font-size: 0.78rem;
    }
    .grid-container {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 10px;
    }
    body.mobile-menu-open .sidebar {
        width: min(360px, 78vw);
        right: auto;
        border-right: 1px solid var(--border);
    }
}
@keyframes floatUp {
    0% { opacity: 0; transform: translateY(30px) scale(0.95); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}
