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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #030303;
    color: #e5e5e5;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

.hidden { display: none !important; }

/* ── LAYOUT ─────────────────────────────────────────────────────────────── */

.Screen { position: fixed; inset: 0; }
.ScreenCenter { display: flex; align-items: center; justify-content: center; height: 100%; padding: 24px; }
.ScreenFull { display: flex; flex-direction: column; height: 100%; }

.Panel { background: #080808; border: 3px solid #121212; width: 100%; max-width: 500px; }
.PanelLarge { max-width: 700px; }

.PanelHeader { background: #0a0a0a; border-bottom: 3px solid #4a9eff; padding: 20px 24px; }
.PanelTitle { font-size: 16px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; }

.PanelBody { padding: 24px; display: flex; flex-direction: column; gap: 12px; }

.ButtonGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.CardButton {
    background: #080808;
    border: 3px solid #121212;
    padding: 32px 24px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    text-align: center;
    color: #e5e5e5;
}
.CardButton:hover { border-color: #4a9eff; background: #0a1a2e; }
.CardIcon { font-size: 40px; margin-bottom: 16px; }
.CardTitle { font-size: 14px; font-weight: 700; text-transform: uppercase; margin-bottom: 8px; }
.CardDescription { font-size: 12px; color: #555; }

.ActionButton {
    background: #080808;
    border: 3px solid #121212;
    color: #e5e5e5;
    padding: 14px 24px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    font-family: inherit;
    width: 100%;
}
.ActionButton:hover { border-color: #4a9eff; background: #0a1a2e; }

.PrimaryButton { background: #4a9eff; border-color: #4a9eff; color: #030303; }
.PrimaryButton:hover { background: #5fadff; border-color: #5fadff; }

.SuccessButton { background: #44ff44; border-color: #44ff44; color: #030303; }
.SuccessButton:hover { background: #55ff55; border-color: #55ff55; }

/* ── TOOLBAR ─────────────────────────────────────────────────────────────── */

.Toolbar {
    background: #080808;
    border-bottom: 3px solid #121212;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
.ToolbarLeft { display: flex; align-items: center; gap: 16px; }
.ToolbarTitle { font-size: 16px; font-weight: 700; text-transform: uppercase; }
.ToolbarCount { font-size: 12px; color: #555; text-transform: uppercase; }
.ToolbarRight { display: flex; gap: 12px; }

.ToolbarButton {
    background: #080808;
    border: 3px solid #121212;
    padding: 10px 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    color: #e5e5e5;
    font-family: inherit;
}
.ToolbarButton:hover { border-color: #4a9eff; background: #0a1a2e; }
.ToolbarButton.PrimaryButton { background: #4a9eff; border-color: #4a9eff; color: #030303; }
.ToolbarButton.PrimaryButton:hover { background: #5fadff; border-color: #5fadff; }

/* ── BULK BAR ─────────────────────────────────────────────────────────────── */

.BulkBar {
    background: #0f0c00;
    border-bottom: 3px solid #ffaa00;
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
.BulkCount { font-size: 11px; font-weight: 700; text-transform: uppercase; color: #ffaa00; }
.BulkActions { display: flex; gap: 8px; }

.BulkActionButton {
    border: 2px solid transparent;
    padding: 8px 16px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    transition: filter 0.15s;
    color: #030303;
    font-family: inherit;
}
.BulkActionButton:hover { filter: brightness(1.15); }

.BulkDeleteButton   { background: #ff4444; }
.BulkMoveButton     { background: #ffaa00; }
.SelectAllButton    { background: #4a9eff; }
.ClearSelectionButton { background: #a855f7; color: #fff; }

/* ── GRID ─────────────────────────────────────────────────────────────────── */

.GridContainer { flex: 1; overflow-y: auto; padding: 20px; }

.GifGrid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

/* ── GIF CARD ─────────────────────────────────────────────────────────────── */

.GifItem {
    position: relative;
    background: #080808;
    border: 3px solid #1a1a1a;
    transition: border-color 0.12s, background 0.12s;
    cursor: default;
}

/* State overlay — covers entire card, used for tint */
.StateOverlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.12s;
}

/* HOVER — only when neither selected nor failed */
.GifItem:not(.selected):not(.failed):hover {
    border-color: #4a9eff;
    background: #050d1a;
}
.GifItem:not(.selected):not(.failed):hover .StateOverlay {
    background: rgba(74, 158, 255, 0.10);
    opacity: 1;
}
.GifItem:not(.selected):not(.failed):hover .GifControls {
    background: #050d1a;
    border-top-color: #4a9eff;
}
.GifItem:not(.selected):not(.failed):hover .PositionValue {
    background: #050d1a;
    border-color: #4a9eff;
}

/* SELECTED */
.GifItem.selected {
    border-color: #ffaa00;
    background: #1a1200;
}
.GifItem.selected .StateOverlay {
    background: rgba(255, 170, 0, 0.13);
    opacity: 1;
}
.GifItem.selected .GifControls {
    background: #1a1200;
    border-top-color: #ffaa00;
}
.GifItem.selected .PositionValue {
    background: #1a1200;
    border-color: #ffaa00;
}

/* FAILED */
.GifItem.failed {
    border-color: #ff4444;
    background: #1a0000;
}
.GifItem.failed .StateOverlay {
    background: rgba(255, 68, 68, 0.12);
    opacity: 1;
}
.GifItem.failed .GifControls {
    background: #1a0000;
    border-top-color: #ff4444;
}
.GifItem.failed .PositionValue {
    background: #1a0000;
    border-color: #ff4444;
    color: #ff4444;
}

/* SELECTED + HOVER (still in select mode, hovering) */
.GifItem.selected:hover {
    border-color: #ffc333;
    background: #221900;
}
.GifItem.selected:hover .GifControls { background: #221900; border-top-color: #ffc333; }
.GifItem.selected:hover .PositionValue { background: #221900; border-color: #ffc333; }

/* ── MEDIA CONTAINER ─────────────────────────────────────────────────────── */

.MediaContainer {
    aspect-ratio: 1;
    background: #030303;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.MediaContainer img,
.MediaContainer video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0;
    transition: opacity 0.25s;
}
.MediaContainer img.loaded,
.MediaContainer video.loaded { opacity: 1; }

.ErrorText {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ff4444;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    z-index: 2;
}

/* ── SPINNER ─────────────────────────────────────────────────────────────── */

.Spinner {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 1;
}
.Spinner > div {
    width: 28px;
    height: 28px;
    border: 3px solid #1a1a1a;
    border-top-color: #4a9eff;
    border-radius: 50%;
    animation: Spin 0.7s linear infinite;
}
.Spinner.hidden { display: none !important; }
@keyframes Spin { to { transform: rotate(360deg); } }

/* ── GIF CONTROLS ────────────────────────────────────────────────────────── */

.GifControls {
    background: #080808;
    border-top: 2px solid #1a1a1a;
    padding: 8px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 46px;
    transition: background 0.12s, border-top-color 0.12s;
    position: relative;
    z-index: 11;
}

.PositionValue {
    font-size: 11px;
    font-weight: 700;
    padding: 6px 10px;
    background: #121212;
    border: 2px solid #1a1a1a;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
    height: 28px;
    display: flex;
    align-items: center;
    user-select: none;
    min-width: 32px;
    justify-content: center;
}
.PositionValue:hover { background: #4a9eff; border-color: #4a9eff; color: #030303; }

.GifActions { display: flex; gap: 5px; }

.GifBtn {
    width: 28px;
    height: 28px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: filter 0.15s;
    flex-shrink: 0;
}
.GifBtn:hover { filter: brightness(1.2); }
.ViewBtn   { background: #4a9eff; }
.RemoveBtn { background: #ff4444; }
.ReloadBtn { background: #ffaa00; }

/* ── SORTABLE ────────────────────────────────────────────────────────────── */

.SortableGhost {
    opacity: 0.35;
    border-color: #4a9eff !important;
}
.SortableDrag {
    opacity: 1 !important;
    box-shadow: 0 12px 40px rgba(0,0,0,0.9), 0 0 0 2px #4a9eff;
    cursor: grabbing !important;
    z-index: 9999 !important;
}

/* ── COLLECTION LIST ─────────────────────────────────────────────────────── */

.CollectionListContainer {
    background: #030303;
    border: 3px solid #121212;
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
    padding: 20px;
}
.CollectionItem {
    background: #080808;
    border: 3px solid #121212;
    padding: 14px 16px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
    transition: border-color 0.15s;
}
.CollectionItem:last-child { margin-bottom: 0; }
.CollectionItem:hover { border-color: #4a9eff; }
.CollectionInfo { font-size: 11px; font-weight: 600; text-transform: uppercase; }
.CollectionRemoveButton {
    background: #ff4444; border: none; padding: 7px 14px;
    font-size: 10px; font-weight: 700; text-transform: uppercase;
    color: #fff; cursor: pointer; transition: filter 0.15s; font-family: inherit;
}
.CollectionRemoveButton:hover { filter: brightness(1.2); }
.CollectionEmpty {
    display: flex; align-items: center; justify-content: center;
    height: 200px; color: #555; font-size: 12px; text-transform: uppercase;
}

/* ── EXPORT ──────────────────────────────────────────────────────────────── */

.ExportContainer { flex: 1; display: flex; flex-direction: column; padding: 24px; overflow: hidden; }
.ExportPreviewWrapper {
    flex: 1; background: #080808; border: 3px solid #121212;
    padding: 20px; margin-bottom: 20px; overflow: auto;
}
.ExportPreview { font-family: "Courier New", monospace; font-size: 11px; color: #555; white-space: pre; }
.ExportActions { display: flex; flex-direction: column; gap: 12px; flex-shrink: 0; }
.ActionRow { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── CONTEXT MENU ────────────────────────────────────────────────────────── */

.ContextMenu {
    position: fixed; background: #080808; border: 3px solid #1a1a1a;
    z-index: 9999; min-width: 160px;
}
.ContextItem {
    padding: 11px 16px; cursor: pointer; font-size: 11px; font-weight: 600;
    text-transform: uppercase; transition: background 0.12s, padding-left 0.12s;
    border-bottom: 1px solid #121212;
}
.ContextItem:last-child { border-bottom: none; }
.ContextItem:hover { background: #111; padding-left: 22px; }

/* ── TOAST ───────────────────────────────────────────────────────────────── */

.Toast {
    position: fixed; bottom: 24px; right: 24px; background: #080808;
    border: 3px solid #4a9eff; padding: 14px 22px; font-size: 11px;
    font-weight: 700; text-transform: uppercase; z-index: 99999;
    animation: ToastIn 0.25s ease;
}
@keyframes ToastIn { from { transform: translateX(110%); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── FOOTER ──────────────────────────────────────────────────────────────── */

.FooterActions {
    background: #080808; border-top: 3px solid #121212;
    padding: 16px 24px; display: flex; gap: 12px; flex-shrink: 0;
}

/* ── FULLSCREEN VIEWER ───────────────────────────────────────────────────── */

.FullscreenViewer {
    position: fixed; inset: 0; background: #000;
    z-index: 10000; display: flex; flex-direction: column;
}
.FsMedia {
    flex: 1; display: flex; align-items: center; justify-content: center;
    position: relative; overflow: hidden;
}
.FsMedia img, .FsMedia video { width: 100%; height: 100%; object-fit: contain; }

.FsNav {
    position: absolute; top: 50%; transform: translateY(-50%);
    width: 60px; height: 60px; background: rgba(8,8,8,0.75);
    border: 3px solid rgba(26,26,26,0.8); color: #e5e5e5;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: background 0.15s, border-color 0.15s; z-index: 10;
}
.FsNav:hover { background: rgba(74,158,255,0.9); border-color: #4a9eff; }
.FsPrev { left: 28px; }
.FsNext { right: 28px; }
.NavDisabled { opacity: 0.2; cursor: not-allowed; pointer-events: none; }

.FsClose {
    position: absolute; top: 28px; right: 28px;
    width: 48px; height: 48px; background: rgba(8,8,8,0.75);
    border: 3px solid rgba(26,26,26,0.8); color: #e5e5e5;
    font-size: 28px; font-weight: 300; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s, border-color 0.15s; z-index: 10;
}
.FsClose:hover { background: rgba(255,68,68,0.9); border-color: #ff4444; }

.FsFooter {
    background: #080808; border-top: 3px solid #121212;
    padding: 18px 28px; display: flex; gap: 14px;
    align-items: center; flex-shrink: 0;
}
.FsInfo { font-size: 14px; font-weight: 700; text-transform: uppercase; margin-right: auto; }

.FsBtn {
    background: #080808; border: 3px solid #121212; padding: 10px 22px;
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    cursor: pointer; transition: background 0.15s, border-color 0.15s;
    color: #e5e5e5; font-family: inherit;
}
.FsBtn:hover { border-color: #4a9eff; background: #0a1a2e; }
.FsCopyBtn   { background: #4a9eff; border-color: #4a9eff; color: #030303; }
.FsCopyBtn:hover { background: #5fadff; border-color: #5fadff; }
.FsDeleteBtn { background: #ff4444; border-color: #ff4444; }
.FsDeleteBtn:hover { background: #ff5555; border-color: #ff5555; }
.FsReloadBtn { background: #ffaa00; border-color: #ffaa00; color: #030303; }
.FsReloadBtn:hover { background: #ffbb22; border-color: #ffbb22; }

/* ── CONFIRM DIALOG ──────────────────────────────────────────────────────── */

.ConfirmOverlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.85);
    z-index: 99999; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.ConfirmBox { background: #080808; border: 3px solid #121212; padding: 32px; max-width: 480px; width: 100%; }
.ConfirmTitle { font-size: 16px; font-weight: 700; text-transform: uppercase; margin-bottom: 16px; }
.ConfirmMessage { font-size: 13px; color: #888; margin-bottom: 24px; line-height: 1.5; }
.ConfirmActions { display: flex; gap: 12px; }
.ConfirmButton {
    flex: 1; background: #080808; border: 3px solid #121212; color: #e5e5e5;
    padding: 12px 24px; font-size: 12px; font-weight: 600; text-transform: uppercase;
    cursor: pointer; transition: border-color 0.15s; font-family: inherit;
}
.ConfirmButton:hover { border-color: #4a9eff; }
.ConfirmDanger { background: #ff4444; border-color: #ff4444; }
.ConfirmDanger:hover { background: #ff5555; border-color: #ff5555; }

/* ── SCROLLBAR ───────────────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #030303; }
::-webkit-scrollbar-thumb { background: #1a1a1a; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #4a9eff; }

/* ── RESPONSIVE ──────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .ButtonGrid { grid-template-columns: 1fr; }
    .ActionRow { grid-template-columns: 1fr; }
    .GifGrid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
    .Toolbar { flex-direction: column; gap: 12px; }
    .ToolbarLeft, .ToolbarRight { width: 100%; justify-content: center; }
    .FooterActions { flex-direction: column; }
}