/* GLOBAL */
body {
    margin: 0;
    background: #111;
    color: #eee;
    font-size: 16px;
    height: 36px;
    font-size: 16px;
    height: 36px;
    font-family: -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}

/* HEADER */
.top-bar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: #111;
    padding: 8px 12px;
    border-bottom: 1px solid #222;
}

.title-row {
    transition: opacity 0.25s ease, height 0.25s ease, margin-bottom 0.25s ease;
    overflow: hidden;
    margin-bottom: 6px;
}

.title-row h1 {
    font-size: 18px;
    margin: 0;
    font-weight: 600;
    line-height: 1.0;
}

/* sort row: media buttons left, sort/shuffle right */
.sort-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.sort-row .media-buttons {
    flex-shrink: 0;
    flex-wrap: wrap;
}

.sort-row .sort-controls {
    flex: 1 1 200px;
}


/* media filter pills */
.media-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.media-btn {
    padding: 4px 10px;
    border-radius: 999px;
    border: none;
    background: #333;
    color: #eee;
    font-size: 16px;
}

.media-btn.active {
    background: #276ef1;
    color: #fff;
}

/* sort controls (right side) */
sort-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.sort-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
    flex: 1 1 auto;
}

.search-input {
    background: #222;
    color: #eee;
    border-radius: 6px;
    border: 1px solid #333;
    padding: 0 8px;
    font-size: 16px;
    height: 36px;
    flex: 1 1 140px;
    max-width: 280px;
    min-width: 140px;
}

.sort-label {
    font-size: 16px;
    opacity: 0.7;
}

.sort-select {
    background: #222;
    color: #eee;
    border-radius: 6px;
    border: 1px solid #333;
    padding: 4px 6px;
    font-size: 16px;
    height: 36px;
}

.count-chip {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    background: #1b1b1b;
    border: 1px solid #333;
    color: #ddd;
    font-size: 14px;
    line-height: 1;
    height: 32px;
    white-space: nowrap;
}

#shuffle-btn, .select-toggle {
    height: 36px;
    padding: 0 10px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    background: #444;
    color: #fff;
}

.select-toggle.active {
    background: #276ef1;
}

/* Selection bar */
.selection-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 0;
}

.selection-bar-hidden {
    display: none;
}

.selection-actions {
    display: flex;
    gap: 6px;
}

$113px;
}

.selection-btn.secondary {
    background: #444;
}

/* TAG FILTER BAR */
.filter-bar {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 6px 0;
}

$112px;
}

.filter-tag.active {
    background: #276ef1;
}

.filter-clear {
    padding: 5px 10px;
    border-radius: 12px;
    background: #822;
    color: #fff;
    border: none;
    white-space: nowrap;
}

/* FEED GRID */
#feed {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
    padding: 8px;
}

.card {
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

.card.selected {
    outline: 2px solid #276ef1;
    outline-offset: -2px;
}

/* thumb tile: vertical rectangle */
.thumb-container {
    position: relative;
    width: 100%;
    padding-top: 140%;
}

.thumb-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* duration badge (videos only) */
.duration-badge {
    position: absolute;
    bottom: 6px;
    right: 6px;
    padding: 2px 5px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 10px;
}

/* TAGS BELOW CARD */
.card-meta {
    padding: 6px;
}

.card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

$111px;
    white-space: nowrap;
}

.tag-badge.add-tag {
    background: #276ef1;
    color: #fff;
}

/* TAG EDITOR */
.tag-picker {
    padding: 8px;
    border-top: 1px solid #222;
    background: #111;
}

.tag-picker-label {
    font-size: 16px;
    margin-bottom: 6px;
    opacity: 0.8;
}

.tag-picker-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    margin-bottom: 6px;
}

$111px;
    white-space: nowrap;
}

.picker-tag-badge.active {
    background: #276ef1;
}

.tag-picker-input {
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 6px;
    padding: 6px;
    border-radius: 4px;
    border: 1px solid #333;
    background: #000;
    color: #eee;
    font-size: 16px;
}

/* action row: ???  ??  ??  ? */
.tag-picker-actions {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 4px;
}

.tag-picker-actions button {
    flex: 1;
    padding: 8px 0;
    border-radius: 10px;
    border: none;
    font-size: 18px;
}

.tag-picker-delete {
    background: #b3261e;
    color: #fff;
}

.tag-picker-thumb {
    background: #444;
    color: #fff;
}

.tag-picker-cancel {
    background: #555;
    color: #fff;
}

.tag-picker-save {
    background: #1c7c3c;
    color: #fff;
}

/* THUMBNAIL MODAL */
.thumb-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.thumb-modal-hidden {
    display: none;
}

.thumb-modal-dialog {
    background: #181818;
    border-radius: 12px;
    padding: 16px;
    width: 90%;
    max-width: 360px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

.thumb-modal-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 10px;
}

.thumb-modal-presets {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.thumb-modal-preset {
    flex: 1;
    padding: 6px 0;
    border-radius: 8px;
    border: none;
    background: #333;
    color: #eee;
    font-size: 16px;
}

.thumb-modal-preset.thumb-preset-active {
    background: #276ef1;
    color: #fff;
}

.thumb-modal-label {
    display: block;
    font-size: 16px;
    margin-bottom: 8px;
}

.thumb-modal-label input {
    width: 100%;
    margin-top: 4px;
    padding: 6px;
    border-radius: 6px;
    border: 1px solid #333;
    background: #000;
    color: #eee;
    box-sizing: border-box;
}

.thumb-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 10px;
}

.thumb-modal-actions button {
    padding: 6px 12px;
    border-radius: 8px;
    border: none;
    font-size: 16px;
}

#thumb-modal-cancel {
    background: #444;
    color: #eee;
}

#thumb-modal-generate {
    background: #276ef1;
    color: #fff;
}

/* IMAGE FULLSCREEN MODAL */
.image-modal {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease-out;
    touch-action: none; /* prevent Safari from treating drag as scroll */
}

.image-modal.visible {
    opacity: 1;
    pointer-events: auto;
}

.image-modal-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain; /* contain vs cover */
    transition: transform 0.2s ease-out;
    user-select: none;
    -webkit-user-drag: none;
}

/* Bulk tag modal */
.bulk-modal {
    overscroll-behavior: contain;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 70;
}

.bulk-modal-hidden {
    display: none;
}

.bulk-modal-dialog {
    background: #181818;
    border-radius: 12px;
    padding: 16px;
    width: 90%;
    max-width: 420px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

.bulk-modal-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 10px;
}

.bulk-preview {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
}

.bulk-preview-img {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #333;
    background: #000;
    display: none;
}


.bulk-tag-list {
    overscroll-behavior: contain;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.bulk-tag-input {
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 8px;
    padding: 6px;
    border-radius: 6px;
    border: 1px solid #333;
    background: #000;
    color: #eee;
    font-size: 16px;
}

.bulk-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 10px;
}

.bulk-btn {
    padding: 6px 12px;
    border-radius: 8px;
    border: none;
    font-size: 16px;
    background: #276ef1;
    color: #fff;
}

.bulk-btn.secondary {
    background: #444;
}

/* Force Safari to dedicate a GPU layer for every thumbnail */
.thumb-container {
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
    contain: layout paint size style;
}

/* Same for images themselves */
.thumb-img {
    will-change: opacity, transform;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* layout fixes: override header alignment and input sizing */
body {
    line-height: 1.4;
    height: auto;
}

.sort-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.sort-row .media-buttons {
    flex: 0 0 auto;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.sort-row .sort-controls {
    flex: 1 1 260px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.media-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.search-input {
    flex: 1 1 200px;
    min-width: 140px;
    max-width: 320px;
    height: 36px;
    font-size: 16px;
}

.sort-select {
    height: 36px;
    font-size: 16px;
}

#shuffle-btn,
.select-toggle {
    height: 36px;
    font-size: 16px;
}




/* tag overrides for consistent pill look */
.tag-badge {
    padding: 3px 7px;
    border-radius: 10px;
    background: #2b2b2b !important;
    color: #fff !important;
    border: none !important;
    font-size: 12px !important;
    font-weight: 500;
    white-space: nowrap;
}
.tag-badge.add-tag {
    background: #276ef1 !important;
    color: #fff !important;
}
.picker-tag-badge {
    padding: 3px 7px;
    border-radius: 10px;
    background: #333 !important;
    color: #fff !important;
    border: none !important;
    font-size: 12px !important;
    white-space: nowrap;
}
.picker-tag-badge.active {
    background: #276ef1 !important;
}
.picker-tag-badge.state-remove {
    background: #742b2b !important;
    color: #fff !important;
    text-decoration: line-through;
}
.picker-tag-badge.common {
    background: #276ef1 !important;
    color: #fff !important;
}
.picker-tag-badge.partial {
    background: #555 !important;
    color: #eee !important;
}
.filter-tag {
    padding: 5px 10px;
    border-radius: 12px !important;
    background: #333 !important;
    color: #fff !important;
    border: none !important;
    white-space: nowrap;
    font-size: 12px !important;
    font-weight: 500;
}
/* select toggle below filter bar */
.select-toggle.select-below {
    margin: 6px 0 0 0;
    align-self: flex-start;
}
/* clamp card tags to one line and keep add button visible */
.card-tags {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    overflow: hidden;
}
.card-tags .tag-badge { flex-shrink: 0; }
.card-tags .tag-badge.add-tag { margin-left: auto; }
.tag-badge.extra-tag {
    background: #3a3a3a !important;
    color: #ccc !important;
}
/* ensure add tag button stays visible at start of tag row */
.card-tags {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    overflow: hidden;
}
.card-tags .tag-badge { flex-shrink: 0; }
.card-tags .tag-badge.add-tag {
    margin-left: 0 !important;
    order: -1;
}
.card-tags .tag-badge.extra-tag { order: 999; }
/* search clear button */
.search-wrap {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1 1 200px;
    min-width: 140px;
}
.search-clear {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: #aaa;
    width: 24px;
    height: 24px;
    font-size: 16px;
    line-height: 1;
    padding: 0;
}
.search-clear:active { color: #fff; }
.search-input {
    padding-right: 28px;
}





