.view--gallery {
    max-width: 1320px;
    margin: 0 auto;
    width: 100%;
    padding-top: .5rem;
}

.gallery-toolbar {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: .75rem;
    margin-bottom: 1.25rem;
    padding: 0 .15rem;
    flex-wrap: wrap;
}

.gallery-search {
    display: flex;
    align-items: center;
    gap: .45rem;
    min-width: min(220px, 100%);
    flex: 1 1 220px;
    padding: .42rem .7rem;
    border-radius: var(--radius-pill);
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
}

.gallery-search svg {
    width: 15px;
    height: 15px;
    color: var(--text-subtle);
    flex-shrink: 0;
}

.gallery-search input {
    border: none;
    background: transparent;
    width: 100%;
    outline: none;
    font-size: .84rem;
}

.gallery-search input::placeholder { color: var(--text-subtle); }

.gallery-toolbar__actions {
    display: flex;
    align-items: center;
    gap: .45rem;
    margin-left: auto;
}

.view--gallery-select .history-card {
    cursor: pointer;
}

.history-card--selected .history-card__thumb {
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85);
}

.history-card__select-wrap {
    position: absolute;
    top: .45rem;
    left: .45rem;
    z-index: 3;
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(8px);
}

.history-card__select {
    width: 14px;
    height: 14px;
    margin: 0;
    accent-color: #fff;
    cursor: pointer;
}

.gallery-filters {
    display: flex;
    gap: .12rem;
    padding: .18rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-pill);
}

.gallery-filter {
    border: none;
    background: transparent;
    color: var(--text-subtle);
    padding: .36rem .82rem;
    border-radius: var(--radius-pill);
    font-size: .76rem;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s var(--ease);
}

.gallery-filter:hover { color: var(--text); }

.gallery-filter--active {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text);
    font-weight: 600;
}

.gallery-refresh svg {
    width: 17px;
    height: 17px;
}

.gallery-page__empty,
.gallery-page__loading,
.gallery-page__error {
    text-align: center;
    color: var(--text-muted);
    padding: 5rem 1rem;
    font-size: .92rem;
}

.gallery-grid {
    width: 100%;
}

.history-card {
    border: none;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: transparent;
    cursor: pointer;
    transition: transform .28s var(--ease);
}

.history-card:hover {
    transform: translateY(-2px);
}

.history-card__thumb {
    position: relative;
    background: #0a0a0a;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.history-card__thumb::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    pointer-events: none;
}

.history-card__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .45s var(--ease), filter .3s var(--ease);
}

.history-card:hover .history-card__thumb img {
    transform: scale(1.02);
}

.history-card__thumb--error::after {
    content: '⚠';
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 1.5rem;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.55);
    box-shadow: none;
}

.history-card__play {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 1.6rem;
    background: rgba(0, 0, 0, 0.25);
    z-index: 1;
    pointer-events: none;
}

.history-card__body {
    padding: .45rem .05rem 0;
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: opacity .2s var(--ease), max-height .25s var(--ease);
}

.history-card:hover .history-card__body,
.history-card:focus-within .history-card__body {
    opacity: 1;
    max-height: 80px;
}

.history-card__mode {
    display: none;
}

.history-card__prompt {
    margin: 0;
    font-size: .76rem;
    line-height: 1.4;
    color: var(--text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.history-card__meta {
    margin: .15rem 0 0;
    font-size: .66rem;
    color: var(--text-subtle);
}

.history-card__videos {
    position: absolute;
    right: .45rem;
    bottom: .45rem;
    z-index: 2;
    padding: .12rem .38rem;
    border-radius: var(--radius-pill);
    background: rgba(59, 130, 246, 0.82);
    backdrop-filter: blur(8px);
    color: #fff;
    font-size: .6rem;
    font-weight: 600;
}

.history-card__edits {
    position: absolute;
    left: .45rem;
    bottom: .45rem;
    z-index: 2;
    padding: .12rem .38rem;
    border-radius: var(--radius-pill);
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    color: #fff;
    font-size: .6rem;
    font-weight: 600;
}

.history-card__actions {
    position: absolute;
    top: .4rem;
    right: .4rem;
    z-index: 2;
    display: flex;
    gap: .28rem;
    opacity: 0;
    transition: opacity .2s var(--ease);
}

.history-card:hover .history-card__actions,
.history-card__actions:focus-within {
    opacity: 1;
}

.history-card__action {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(8px);
    color: #fff;
    font-size: .75rem;
    cursor: pointer;
    transition: background .2s var(--ease), color .2s var(--ease);
}

.history-card__action:hover {
    background: rgba(255, 255, 255, 0.92);
    color: #000;
}

.history-card__action svg {
    width: 14px;
    height: 14px;
    display: block;
}

.history-card__action--delete:hover {
    background: rgba(248, 113, 113, 0.92);
    color: #fff;
}

.history-card__action--pin.history-card__action--active,
.history-card__action--active {
    color: #fbbf24;
}

.history-card__action--reload:hover {
    background: rgba(124, 108, 255, 0.92);
    color: #fff;
}

.history-card--pinned .history-card__thumb {
    box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.35);
}

.history-card__pin {
    position: absolute;
    top: .45rem;
    right: .45rem;
    z-index: 2;
    color: #fbbf24;
    font-size: .72rem;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}

.history-card__hover-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
}

.history-card--skeleton .history-card__body {
    padding: .65rem .75rem .8rem;
}

.history-card--removing {
    opacity: .35;
    transform: scale(.98);
    transition: opacity .2s, transform .2s;
}

.history-card__thumb--error {
    background: rgba(255, 255, 255, 0.04);
}