.user-history-page {
    width: min(960px, 100%);
    min-height: calc(100vh - 68px);
    margin: 0 auto;
    padding-bottom: 28px;
    background: var(--surface, #fff);
    color: var(--text, #171717);
}

.history-auth-intro {
    margin: 4px 38px 2px;
    color: #70737a;
    font-size: clamp(12px, 3.45vw, 13px);
    line-height: 1.55;
    text-align: center;
}

.user-history-page__topbar {
    position: sticky;
    z-index: 30;
    top: 0;
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr) 52px;
    align-items: center;
    min-height: 56px;
    border-bottom: 1px solid color-mix(in srgb, var(--line, #ececec) 78%, transparent);
    background: color-mix(in srgb, var(--surface, #fff) 94%, transparent);
    backdrop-filter: blur(16px);
}

.user-history-page__back,
.user-history-page__manage {
    display: grid;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font: inherit;
    text-decoration: none;
    place-items: center;
}

.user-history-page__back {
    font-size: 36px;
    font-weight: 300;
    line-height: 1;
}

.user-history-page__manage {
    justify-self: end;
    color: var(--text, #171717);
    border-radius: 50%;
    transition: color .16s ease, background-color .16s ease, transform .16s ease;
}

.user-history-page__manage:hover,
.user-history-page__manage:focus-visible,
.user-history-page__manage.is-active {
    background: color-mix(in srgb, var(--text, #171717) 7%, transparent);
    color: var(--template-primary, #ff4f8b);
}

.user-history-page__manage:active {
    transform: scale(.94);
}

.user-history-page__manage:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--template-primary, #ff4f8b) 38%, transparent);
    outline-offset: -3px;
}

.user-history-page__manage svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.user-history-page__title {
    margin: 0;
    overflow: hidden;
    font-size: clamp(17px, 4.8vw, 18px);
    font-weight: 700;
    line-height: 1.3;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-history-filters {
    position: sticky;
    z-index: 25;
    top: 56px;
    display: grid;
    grid-template-columns: repeat(5, minmax(62px, 1fr));
    margin: 0;
    padding: 0 10px;
    overflow-x: auto;
    border-bottom: 1px solid color-mix(in srgb, var(--line, #ececec) 78%, transparent);
    background: color-mix(in srgb, var(--surface, #fff) 96%, transparent);
    scrollbar-width: none;
}

.user-history-filters::-webkit-scrollbar {
    display: none;
}

.user-history-filter {
    position: relative;
    display: grid;
    min-height: 48px;
    padding: 0 7px;
    color: var(--muted, #777);
    font-size: clamp(13px, 3.75vw, 14px);
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
    place-items: center;
}

.user-history-filter.is-active {
    color: var(--text, #171717);
    font-weight: 700;
}

.user-history-filter.is-active::after {
    position: absolute;
    right: 18px;
    bottom: 0;
    left: 18px;
    height: 3px;
    border-radius: 3px 3px 0 0;
    background: var(--accent, #ef2b3a);
    content: "";
}

.user-history-actions {
    display: flex;
    align-items: center;
    min-height: 42px;
    padding: 7px 14px 0;
    gap: 10px;
}

.user-history-actions__feedback {
    overflow: hidden;
    color: var(--muted, #8a8a8a);
    font-size: clamp(11px, 3.2vw, 12px);
    line-height: 1.4;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-history-actions__feedback {
    min-width: 0;
    flex: 1 1 auto;
    text-align: right;
}

.user-history-actions__feedback.is-error {
    color: #c62828;
}

.user-history-actions__clear,
.user-history-card__delete,
.user-history-confirm__cancel,
.user-history-confirm__submit {
    font: inherit;
    cursor: pointer;
}

.user-history-actions__clear {
    flex: 0 0 auto;
    min-height: 30px;
    padding: 4px 10px;
    border: 0;
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent, #ef2b3a) 10%, #fff);
    color: var(--accent, #ef2b3a);
    font-size: clamp(11px, 3.2vw, 12px);
}

.user-history-page__state {
    margin: 24px 14px;
    padding: 54px 20px;
    border-radius: 14px;
    background: color-mix(in srgb, var(--page-bg, #f5f5f5) 78%, #fff);
    color: var(--muted, #777);
    text-align: center;
}

.user-history-page__state-title {
    margin: 0 0 8px;
    color: var(--text, #171717);
    font-size: clamp(17px, 4.8vw, 18px);
}

.user-history-page__state-text {
    margin: 0;
    font-size: clamp(12px, 3.45vw, 13px);
    line-height: 1.7;
}

.user-history-page__state-login {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    margin: -3px 0;
    padding: 2px 10px;
    border: 0;
    border-radius: 999px;
    outline: none;
    background: color-mix(in srgb, var(--template-primary, #ff4f8b) 12%, transparent);
    color: var(--template-primary, #ff4f8b);
    cursor: pointer;
    font: inherit;
    font-weight: 750;
    line-height: 1.4;
    vertical-align: middle;
    transition: background-color .16s ease, transform .16s ease;
}

.user-history-page__state-login[hidden] {
    display: none;
}

.user-history-page__state-login:hover,
.user-history-page__state-login:focus-visible {
    background: color-mix(in srgb, var(--template-primary, #ff4f8b) 20%, transparent);
}

.user-history-page__state-login:focus-visible {
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--template-primary, #ff4f8b) 28%, transparent);
}

.user-history-page__state-login:active {
    transform: scale(.96);
}

.user-history-list {
    padding: 0 14px;
}

.user-history-group {
    margin-top: 12px;
}

.user-history-group + .user-history-group {
    margin-top: 24px;
}

.user-history-group__title {
    margin: 0 0 11px;
    font-size: clamp(15px, 4.3vw, 16px);
    font-weight: 700;
    line-height: 1.4;
}

.user-history-group__grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 18px 11px;
}

.user-history-card {
    position: relative;
    min-width: 0;
}

.user-history-card__link {
    display: block;
    min-width: 0;
    color: inherit;
    text-decoration: none;
}

.user-history-card__media {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    border-radius: 8px;
    background: var(--page-bg, #ededed);
}

.user-history-card__media::after {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 42%;
    background: linear-gradient(transparent, rgba(0, 0, 0, .68));
    content: "";
    pointer-events: none;
}

.user-history-card__cover {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .2s ease;
}

.user-history-card__link:hover .user-history-card__cover {
    transform: scale(1.025);
}

.user-history-card__progress {
    position: absolute;
    z-index: 2;
    color: #fff;
    font-size: clamp(10px, 2.9vw, 11px);
    line-height: 1.25;
}

.user-history-card__progress {
    right: 7px;
    bottom: 7px;
    left: 7px;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .4);
    white-space: nowrap;
}

.user-history-card__body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 3px 5px;
    padding: 7px 2px 0;
}

.user-history-card__title {
    display: -webkit-box;
    grid-column: 1 / -1;
    min-height: 36px;
    margin: 0;
    overflow: hidden;
    font-size: clamp(12px, 3.45vw, 13px);
    font-weight: 600;
    line-height: 1.38;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.user-history-card__chapter,
.user-history-card__time {
    overflow: hidden;
    color: var(--muted, #8a8a8a);
    font-size: clamp(10px, 2.9vw, 11px);
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-history-card__time {
    text-align: right;
}

.user-history-card__delete {
    position: absolute;
    z-index: 5;
    top: 6px;
    right: 6px;
    display: grid;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 2px solid #fff;
    border-radius: 50%;
    background: rgba(16, 16, 16, .82);
    color: #fff;
    font-size: 20px;
    line-height: 1;
    opacity: 0;
    pointer-events: none;
    transform: scale(.8);
    transition: opacity .16s ease, transform .16s ease;
    place-items: center;
}

.user-history-page[data-history-managing="1"] .user-history-card__delete {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
}

.user-history-page[data-history-managing="1"] .user-history-card__link {
    opacity: .72;
    pointer-events: none;
}

.user-history-actions__clear:disabled,
.user-history-card__delete:disabled,
.user-history-confirm__cancel:disabled,
.user-history-confirm__submit:disabled {
    cursor: wait;
    opacity: .55;
}

.user-history-page__more {
    display: block;
    width: min(260px, calc(100% - 28px));
    min-height: 42px;
    margin: 24px auto 0;
    padding: 8px 16px;
    border: 0;
    border-radius: 999px;
    background: var(--page-bg, #f3f3f3);
    color: var(--text, #171717);
    cursor: pointer;
    font: inherit;
}

.user-history-page__more:disabled {
    cursor: wait;
    opacity: .6;
}

body.has-history-confirm {
    overflow: hidden;
}

.user-history-confirm {
    position: fixed;
    z-index: 160;
    inset: 0;
    display: grid;
    padding: 20px;
    place-items: center;
}

.user-history-confirm__backdrop {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: rgba(0, 0, 0, .56);
}

.user-history-confirm__panel {
    position: relative;
    width: min(400px, 100%);
    padding: 22px;
    border-radius: 18px;
    background: var(--surface, #fff);
    box-shadow: 0 22px 70px rgba(0, 0, 0, .24);
    color: var(--text, #171717);
}

.user-history-confirm__title {
    margin: 0;
    font-size: clamp(18px, 5.1vw, 19px);
}

.user-history-confirm__text {
    margin: 10px 0 0;
    color: var(--muted, #777);
    font-size: clamp(13px, 3.75vw, 14px);
    line-height: 1.65;
}

.user-history-confirm__buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 20px;
}

.user-history-confirm__cancel,
.user-history-confirm__submit {
    min-height: 42px;
    padding: 8px 14px;
    border: 0;
    border-radius: 9px;
}

.user-history-confirm__cancel {
    background: var(--page-bg, #f3f3f3);
    color: var(--text, #171717);
}

.user-history-confirm__submit {
    background: var(--accent, #ef2b3a);
    color: #fff;
}

[hidden] {
    display: none !important;
}

@media (max-width: 960px) {
    .user-history-group__grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 680px) {
    .user-history-page {
        width: 100%;
        min-height: calc(100vh - 68px);
        padding-bottom: 18px;
    }

    .user-history-page__topbar {
        grid-template-columns: 50px minmax(0, 1fr) 50px;
    }

    .user-history-filters {
        padding: 0 4px;
    }

    .user-history-filter {
        min-width: 62px;
        padding-inline: 5px;
    }

    .user-history-actions {
        padding-inline: 12px;
    }

    .user-history-list {
        padding: 0 10px;
    }

    .user-history-group__grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 16px 8px;
    }

    .user-history-card__media {
        border-radius: 7px;
    }

    .user-history-card__title {
        min-height: 34px;
        font-size: clamp(11px, 3.2vw, 12px);
    }

    .user-history-confirm {
        align-items: end;
        padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
    }

    .user-history-confirm__panel {
        padding: 20px;
        border-radius: 18px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .user-history-card__cover,
    .user-history-card__delete {
        transition: none;
    }
}
