@media (max-width: 480px) {
    .container {
        padding: 0 0.5rem;
    }
    
    .profile-cover {
        height: 150px;
    }
    
    .profile-header {
        border-radius: 16px;
    }
    
    .profile-info {
        padding: 0 0.75rem 1rem;
    }
    
    .profile-avatar,
    .profile-avatar-placeholder {
        width: 80px;
        height: 80px;
        font-size: 1.75rem;
        border-width: 3px;
    }
    
    .profile-avatar-section {
        margin-top: -2.5rem;
    }
    
    .btn-change-cover {
        bottom: auto;
        top: 0.75rem;
        right: 0.75rem;
    }
    
    .btn-change-avatar {
        width: 30px;
        height: 30px;
    }
    
    .btn-change-avatar svg {
        width: 16px;
        height: 16px;
    }
    
    .profile-name {
        font-size: 1.25rem;
    }
    
    .profile-username {
        font-size: 0.875rem;
    }
    
    .profile-bio {
        font-size: 0.8125rem;
    }
    
    .profile-meta {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .meta-item {
        font-size: 0.75rem;
    }
    
    .profile-stats {
        gap: 1rem;
        padding: 0.75rem 0;
    }
    
    .stat-value {
        font-size: 1.125rem;
    }
    
    .stat-label {
        font-size: 0.6875rem;
    }
    
    .gallery-item,
    .gallery-album-item {
        width: 90px;
        height: 90px;
    }
    
    .gallery-article-item,
    .article-create-button {
        width: 110px;
        height: 150px;
    }
    
    .gallery-item.clip-item {
        width: 100px;
    }
    
    .article-info {
        padding: 8px;
    }
    
    .article-title {
        font-size: 0.75rem;
    }
    
    .create-post-card {
        padding: 0.75rem;
    }
    
    .create-post-avatar,
    .create-post-avatar-placeholder {
        width: 36px;
        height: 36px;
    }
    
    .post-input {
        font-size: 0.8125rem;
        padding: 0.5rem 0.75rem;
    }
    
    .post-option-item {
        flex: 1 1 calc(50% - 0.25rem);
        font-size: 0.6875rem;
        padding: 0.375rem;
    }
    
    .post-option-item svg {
        width: 14px;
        height: 14px;
    }
    
    .post-attachments .attachment-btn,
    .post-attachments .create-clip-btn {
        flex: 1 1 calc(33.333% - 0.333rem);
        padding: 0.5rem;
        font-size: 0.75rem;
    }
    
    .attachment-preview {
        width: 80px;
        height: 80px;
    }
    
    .post-header {
        padding: 0.75rem;
    }
    
    .post-author-avatar,
    .post-author-placeholder {
        width: 34px;
        height: 34px;
    }
    
    .post-author-name {
        font-size: 0.8125rem;
    }
    
    .post-content {
        padding: 0 0.75rem 0.75rem;
    }
    
    .post-text {
        font-size: 0.8125rem;
    }
    
    .comment-avatar,
    .comment-avatar-placeholder {
        width: 26px;
        height: 26px;
        font-size: 0.625rem;
    }
    
    .comment-author {
        font-size: 0.6875rem;
    }
    
    .comment-text {
        font-size: 0.75rem;
    }
    
    .comment-replies {
        margin-left: 30px;
    }
    
    .comment-replies .comment-replies {
        margin-left: 16px;
    }
    
    .comment-replies .comment-replies .comment-replies {
        margin-left: 4px;
    }
    
    .comment-replies .comment-replies .comment-replies .comment-replies {
        margin-left: 0;
    }
    
    .comment-reply-input,
    .comment-input {
        font-size: 0.75rem;
        padding: 0.375rem 0.75rem;
    }
    
    .comment-submit,
    .comment-reply-submit {
        width: 30px;
        height: 30px;
    }
    
    .clip-author-avatar,
    .clip-author-placeholder {
        width: 34px;
        height: 34px;
    }
    
    .clip-author-name {
        font-size: 13px;
    }
    
    .clip-description {
        font-size: 12px;
        max-height: 50px;
    }
    
    .clip-action-btn {
        width: 38px;
        height: 38px;
    }
    
    .clip-action-btn svg {
        width: 18px;
        height: 18px;
    }
    
    .clip-comments-panel {
        height: 85%;
    }
    
    .clip-comments-header {
        padding: 12px;
    }
    
    .clip-comment-avatar,
    .clip-comment-avatar-placeholder {
        width: 28px;
        height: 28px;
        font-size: 11px;
    }
    
    .clip-comment-input-wrapper {
        padding: 10px;
        gap: 8px;
    }
    
    .clip-comment-input {
        padding: 8px 14px;
        font-size: 12px;
        border-radius: 20px;
    }
    
    .clip-comment-submit {
        width: 32px;
        height: 32px;
    }
    
    .story-preview-item {
        width: 45px;
        height: 65px;
    }
    
    .story-user-avatar,
    .story-user-avatar-placeholder {
        width: 32px;
        height: 32px;
    }
    
    .story-control-btn {
        width: 28px;
        height: 28px;
    }
    
    .story-control-btn.story-report-btn {
        width: 28px;
        height: 28px;
    }
    
    .story-control-btn.story-report-btn svg {
        width: 16px;
        height: 16px;
    }
    
    .story-comment-report-btn {
        font-size: 10px;
    }
    
    .lightbox-content {
        padding: 44px 4px 70px;
    }
    
    .lightbox-header {
        padding: 0.5rem 0.75rem;
    }
    
    .lightbox-nav {
        width: 32px;
        height: 32px;
    }
    
    .lightbox-thumbnail {
        width: 40px;
        height: 40px;
    }
    
    .lightbox-audio-container {
        width: calc(100vw - 1.5rem);
        padding: 1.25rem 0.75rem;
        gap: 1rem;
    }
    
    .lightbox-audio-container .audio-visualization {
        width: 70px;
        height: 70px;
    }
    
    .lightbox-audio-container .audio-visualization svg {
        width: 40px;
        height: 40px;
    }
    
    .lightbox-audio-container .audio-play-btn {
        width: 36px;
        height: 36px;
    }
    
    .lightbox-audio-container .audio-title {
        font-size: 0.75rem;
    }
    
    .lightbox-audio-container .audio-time {
        font-size: 0.625rem;
    }
    
    .lightbox-audio-container .volume-slider {
        width: 50px;
    }
    
    .modern-audio-player {
        padding: 0.5rem 0.625rem;
    }
    
    .audio-play-btn {
        width: 28px;
        height: 28px;
    }
    
    .audio-play-btn svg {
        width: 12px;
        height: 12px;
    }
    
    .audio-title {
        font-size: 0.6875rem;
    }
    
    .audio-time {
        font-size: 0.5625rem;
        min-width: 24px;
    }
    
    .audio-volume-control {
        display: none;
    }
    
    .album-menu-btn {
        width: 24px;
        height: 24px;
    }
    
    .album-menu-btn svg {
        width: 12px;
        height: 12px;
    }
    
    .album-dropdown-menu {
        min-width: 150px;
    }
    
    .album-menu-item {
        padding: 8px 10px;
        font-size: 12px;
    }
    
    .album-modal-report {
        width: 32px;
        height: 32px;
    }
    
    .album-modal-report svg {
        width: 16px;
        height: 16px;
    }
    
    .clip-dropdown-menu {
        min-width: 150px;
    }
    
    .clip-menu-item {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .clips-header-volume {
        padding: 5px 8px;
    }
    
    .clips-header-volume-slider {
        width: 40px;
    }
    
    /* Story modal */
    .story-modal-content {
        max-height: 98vh;
        border-radius: 20px 20px 0 0;
    }
    
    .story-modal-header {
        padding: 0.875rem 1rem;
    }
    
    .story-modal-header h3 {
        font-size: 0.875rem;
    }
    
    .modal-close {
        width: 28px;
        height: 28px;
    }
    
    .modal-close svg {
        width: 16px;
        height: 16px;
    }
    
    .story-modal-body {
        padding: 1rem;
        max-height: calc(98vh - 130px);
    }
    
    .story-upload-area {
        padding: 1.75rem 1rem;
        border-radius: 16px;
    }
    
    .story-upload-area svg {
        width: 36px;
        height: 36px;
        margin-bottom: 0.75rem;
    }
    
    .story-upload-area p {
        font-size: 0.8125rem;
    }
    
    .story-upload-area span {
        font-size: 0.6875rem;
    }
    
    .story-preview-wrapper {
        max-height: 350px;
        padding-bottom: 125%;
        border-radius: 14px;
    }
    
    .story-text-input {
        padding: 0.75rem 0.875rem;
        font-size: 0.8125rem;
        min-height: 80px;
        border-radius: 12px;
        margin-top: 0.875rem;
    }
    
    .story-char-counter {
        font-size: 0.625rem;
    }
    
    .story-options {
        flex-direction: column;
        padding: 0.75rem;
    }
    
    .story-option-item {
        width: 100%;
        justify-content: center;
        font-size: 0.6875rem;
    }
    
    .story-modal-footer {
        padding: 0.875rem 1rem;
    }
    
    .story-modal-footer .btn {
        padding: 0.625rem 1rem;
        font-size: 0.8125rem;
    }
    
    .story-format-indicator,
    .story-fit-toggle {
        font-size: 0.625rem;
        padding: 0.3125rem 0.5rem;
    }
    
    .story-format-indicator svg,
    .story-fit-toggle svg {
        width: 11px;
        height: 11px;
    }
    
    .story-orientation-warning {
        padding: 0.5rem 0.75rem;
        gap: 0.5rem;
        border-radius: 8px;
    }
    
    .story-orientation-warning svg {
        width: 16px;
        height: 16px;
    }
    
    .story-orientation-warning p {
        font-size: 0.6875rem;
    }
    
    .story-preview-play-btn {
        width: 32px;
        height: 32px;
    }
    
    .story-preview-play-btn svg {
        width: 14px;
        height: 14px;
    }
    
    .story-preview-volume {
        width: 28px;
        height: 28px;
    }
    
    .story-preview-volume svg {
        width: 12px;
        height: 12px;
    }
}

/* === ОЧЕНЬ МАЛЕНЬКИЕ (до 374px) === */
@media (max-width: 374px) {
    .container {
        padding: 0 0.375rem;
    }
    
    .profile-cover {
        height: 130px;
    }
    
    .profile-info {
        padding: 0 0.5rem 0.75rem;
    }
    
    .profile-avatar,
    .profile-avatar-placeholder {
        width: 70px;
        height: 70px;
        font-size: 1.5rem;
    }
    
    .profile-name {
        font-size: 1.125rem;
    }
    
    .profile-username {
        font-size: 0.8125rem;
    }
    
    .profile-stats {
        gap: 0.75rem;
    }
    
    .stat-value {
        font-size: 1rem;
    }
    
    .gallery-item,
    .gallery-album-item {
        width: 75px;
        height: 75px;
    }
    
    .gallery-article-item,
    .article-create-button {
        width: 90px;
        height: 130px;
    }
    
    .gallery-item.clip-item {
        width: 80px;
    }
    
    .create-post-avatar,
    .create-post-avatar-placeholder {
        width: 32px;
        height: 32px;
    }
    
    .post-input {
        font-size: 0.75rem;
    }
    
    .attachment-preview {
        width: 70px;
        height: 70px;
    }
    
    .post-author-avatar,
    .post-author-placeholder {
        width: 30px;
        height: 30px;
    }
    
    .comment-avatar,
    .comment-avatar-placeholder {
        width: 24px;
        height: 24px;
    }
    
    .comment-replies {
        margin-left: 24px;
    }
    
    .comment-replies .comment-replies {
        margin-left: 12px;
    }
    
    .comment-replies .comment-replies .comment-replies {
        margin-left: 0;
    }
    
    .post-comments {
        padding: 0.375rem 0.5rem 0.5rem;
    }
    
    .comment {
        padding: 0.375rem 0.125rem;
    }
    
    .comment-author {
        font-size: 0.7rem;
    }
    
    .comment-text {
        font-size: 0.7rem;
    }
    
    .comment-reply-input {
        font-size: 0.7rem;
        padding: 0.375rem 0.5rem;
    }
    
    .comment-input {
        font-size: 0.7rem;
        padding: 0.375rem 0.625rem;
    }
    
    .lightbox-audio-container {
        width: calc(100vw - 1rem);
        padding: 1rem 0.5rem;
        gap: 0.875rem;
    }
    
    .lightbox-audio-container .audio-visualization {
        width: 60px;
        height: 60px;
    }
    
    .lightbox-audio-container .audio-visualization svg {
        width: 35px;
        height: 35px;
    }
    
    .lightbox-audio-container .audio-play-btn {
        width: 32px;
        height: 32px;
    }
    
    .lightbox-audio-container .audio-play-btn svg {
        width: 14px;
        height: 14px;
    }
    
    .lightbox-audio-container .audio-title {
        font-size: 0.7rem;
    }
    
    .lightbox-audio-container .audio-time {
        font-size: 0.6rem;
    }
    
    .lightbox-audio-container .volume-btn {
        width: 24px;
        height: 24px;
    }
    
    .lightbox-audio-container .volume-slider {
        width: 45px;
    }
    
    .story-control-btn.story-report-btn {
        width: 26px;
        height: 26px;
    }
    
    .story-control-btn.story-report-btn svg {
        width: 14px;
        height: 14px;
    }
    
    /* Story modal */
    .story-modal-header {
        padding: 0.75rem 0.875rem;
    }
    
    .story-modal-header::before {
        width: 32px;
        height: 3px;
        top: 6px;
    }
    
    .story-modal-header h3 {
        font-size: 0.8125rem;
        margin-top: 6px;
    }
    
    .modal-close {
        width: 26px;
        height: 26px;
        margin-top: 6px;
    }
    
    .modal-close svg {
        width: 14px;
        height: 14px;
    }
    
    .story-modal-body {
        padding: 0.875rem;
        max-height: calc(98vh - 120px);
    }
    
    .story-upload-area {
        padding: 1.5rem 0.875rem;
        border-radius: 14px;
    }
    
    .story-upload-area svg {
        width: 32px;
        height: 32px;
    }
    
    .story-upload-area p {
        font-size: 0.75rem;
    }
    
    .story-upload-area span {
        font-size: 0.625rem;
    }
    
    .story-preview-wrapper {
        max-height: 320px;
        padding-bottom: 120%;
        border-radius: 12px;
    }
    
    .story-text-input {
        padding: 0.625rem 0.75rem;
        font-size: 0.75rem;
        min-height: 70px;
        border-radius: 10px;
    }
    
    .story-char-counter {
        font-size: 0.5625rem;
    }
    
    .story-modal-footer {
        padding: 0.75rem 0.875rem;
    }
    
    .story-modal-footer .btn {
        padding: 0.5625rem 0.875rem;
        font-size: 0.75rem;
    }
    
    .clips-header-volume {
        padding: 5px 8px;
    }
    
    .clips-header-volume-slider {
        width: 40px;
    }
}

/* === ЛАНДШАФТ МОБИЛЬНЫХ === */
@media (max-width: 767px) and (orientation: landscape) {
    .profile-avatar-section {
        flex-direction: row;
        text-align: left;
        align-items: flex-start;
    }
    
    .profile-details {
        align-items: flex-start;
    }
    
    .profile-meta {
        justify-content: flex-start;
    }
    
    .profile-actions {
        justify-content: flex-start;
        margin-top: 0;
    }
    
    .profile-stats {
        justify-content: flex-start;
    }
    
    .comments-list {
        max-height: 200px;
    }
    
    .lightbox-audio-container {
        flex-direction: row;
        width: auto;
        max-width: 90vw;
        gap: 1rem;
        padding: 1rem 1.5rem;
    }
    
    .lightbox-audio-container .audio-visualization {
        width: 60px;
        height: 60px;
        flex-shrink: 0;
    }
    
    .lightbox-audio-container .modern-audio-player {
        flex: 1;
        min-width: 0;
    }
    
    .lightbox-audio-container .audio-title {
        text-align: left;
    }
    
    /* Story modal */
    .story-modal {
        align-items: center;
        padding: 0.5rem;
    }
    
    .story-modal-content {
        max-height: 95vh;
        border-radius: 20px;
    }
    
    .story-modal-header::before {
        display: none;
    }
    
    .story-modal-header h3 {
        margin-top: 0;
    }
    
    .modal-close {
        margin-top: 0;
    }
    
    .story-modal-body {
        max-height: calc(95vh - 140px);
    }
    
    .story-preview-wrapper {
        max-height: 300px;
        padding-bottom: 100%;
    }
    
    .story-options {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .story-option-item {
        flex: 1;
        min-width: calc(50% - 0.25rem);
    }
    
    .clips-header-volume {
        padding: 5px 8px;
    }
    
    .clips-header-volume-btn {
        width: 26px;
        height: 26px;
    }
    
    .clips-header-volume-slider {
        width: 40px;
    }
}

/* === СЕНСОРНЫЕ УСТРОЙСТВА === */
@media (hover: none) and (pointer: coarse) {
    .btn,
    .attachment-btn,
    .visibility-button,
    .post-menu-btn,
    .friend-menu-btn,
    .comment-action-btn,
    .profile-menu-btn {
        min-height: 44px;
    }
    
    .comment-reply-btn,
    .comment-edit-btn,
    .comment-delete-btn {
        min-height: 32px;
        min-width: 48px;
        padding: 0.375rem 0.5rem;
    }
    
    .comment-submit,
    .comment-reply-submit {
        min-width: 40px;
        min-height: 40px;
    }
    
    .gallery-nav {
        display: none;
    }
    
    .album-photo-remove,
    .article-menu-btn,
    .album-menu-btn {
        opacity: 1;
    }
    
    .comment-actions {
        display: flex;
    }
    
    .story-upload-area {
        min-height: 160px;
    }
    
    .modal-close,
    .story-preview-play-btn,
    .story-preview-volume,
    .story-fit-toggle {
        min-width: 44px;
        min-height: 44px;
    }
    
    .story-modal-footer .btn {
        min-height: 44px;
    }
    
    .story-text-input {
        padding: 1rem;
        line-height: 1.6;
    }
    
    .lightbox-audio-container .audio-play-btn {
        min-width: 44px;
        min-height: 44px;
    }
    
    .lightbox-audio-container .volume-btn {
        min-width: 32px;
        min-height: 32px;
    }
    
    .lightbox-audio-container .audio-progress-handle {
        transform: translate(-50%, -50%) scale(1.2);
    }
    
    .audio-volume-control .volume-slider-wrapper {
        transition: opacity 0.2s ease, width 0.2s ease;
    }
    
    .audio-volume-control.active .volume-slider-wrapper {
        opacity: 1;
        pointer-events: all;
        width: 140px;
    }
}

/* === iOS SAFE AREA === */
@supports (-webkit-touch-callout: none) {
    .story-modal-content {
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .story-modal-footer {
        padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    }
    
    .modal-footer {
        padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    }
    
    .album-create-footer {
        padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
    }
    
    .album-select-footer {
        padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
    }
    
    .clip-comment-input-wrapper {
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    }
}

/* === REDUCED MOTION === */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .story-control-btn.story-report-btn.has-report {
        animation: none;
    }
    
    .album-menu-btn.has-report,
    .album-modal-report.has-report {
        animation: none;
    }
}

/* === SLOW CONNECTIONS === */
@media (prefers-reduced-data: reduce) {
    .story-upload-area::before {
        display: none;
    }
    
    .story-modal-content {
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    }
}

/* === ПЕЧАТЬ === */
@media print {
    .profile-actions,
    .create-post-card,
    .post-interaction-bar,
    .post-comments,
    .profile-media-gallery,
    .profile-sidebar-mobile,
    .profile-sidebar,
    .btn-change-cover,
    .btn-change-avatar,
    .stories-section {
        display: none !important;
    }
    
    .content-layout {
        display: block;
    }
    
    .profile-page {
        background: white !important;
    }
    
    .post-card {
        page-break-inside: avoid;
        border: 1px solid #ddd !important;
        box-shadow: none !important;
    }
}

/* Отключаем перехват кликов для контейнеров */
.profile-info {
    pointer-events: none;
}

.profile-avatar-section {
    pointer-events: none;
}

/* Включаем клики для всех интерактивных элементов внутри */
.profile-avatar-wrapper,
.profile-avatar,
.profile-avatar-placeholder,
.btn-change-avatar,
#avatarInput,
.online-indicator,
.profile-details,
.profile-details *,
.profile-name,
.profile-username,
.profile-status,
.profile-bio,
.profile-meta,
.profile-meta a,
.meta-item,
.profile-actions,
.profile-actions *,
.profile-stats,
.stat-item,
.btn,
.btn-secondary,
.btn-primary,
.profile-menu-btn,
.profile-dropdown-menu,
.profile-menu-item {
    pointer-events: auto;
}

/* Гарантируем доступность кнопки смены обложки */
.btn-change-cover {
    pointer-events: auto !important;
    z-index: 100 !important;
}

#coverInput {
    pointer-events: auto !important;
}

.profile-dropdown-menu.dropdown-left {
    transform: translateX(-100%);
    margin-left: -8px;
}

@media (max-width: 767px) {
    .profile-dropdown-menu {
        right: 10px !important;
        left: auto !important;
    }
}

@media (max-width: 480px) {
    .profile-dropdown-menu {
        right: 6px !important;
        left: auto !important;
        min-width: 180px;
        max-width: calc(100vw - 12px);
    }
}

@media (max-width: 991px) {
    /* Убираем grid и делаем единый flex-контейнер */
    .content-layout {
        display: flex;
        flex-direction: column;
        gap: 1.5rem;
        max-width: 100%;
    }

    /* Все дочерние блоки занимают полную ширину */
    .content-layout > * {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .profile-content {
        width: 100%;
        max-width: 100%;
    }

    .profile-posts-section {
        width: 100%;
        max-width: 100%;
    }

    /* Мобильный сайдбар — та же ширина что и посты */
    .profile-sidebar-mobile {
        display: block;
        width: 100%;
        max-width: 100%;
    }

    .profile-sidebar-mobile .stories-section,
    .profile-sidebar-mobile .friends-widget {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Форма создания поста — полная ширина */
    .create-post-card {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Карточки постов — полная ширина */
    .posts-container {
        width: 100%;
        max-width: 100%;
    }

    .post-card {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
}
