/* マイページ専用スタイル - 新レイアウト */

.profile-page-new {
    /* sticky の top 計算用（ヘッダー下のグレー帯の上余白と一致させる） */
    --profile-page-pad-top: 30px;
    min-height: 100vh;
    background: var(--color-bg);
    padding: var(--profile-page-pad-top) 0;
    /* styles.css の overflow-x:hidden は overflow-y を auto 扱いにし sticky の基準が変わる → clip で横だけ隠す */
    overflow-x: clip !important;
    overflow-y: visible !important;
}

/* グリッド＋sticky で DM タブ時に左バーが縦にずれる事例があるため、flex＋上揃えで統一 */
.profile-layout {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: flex-start;
    align-content: flex-start;
    justify-content: flex-start;
    gap: 28px;
    overflow: visible;
    width: min(1280px, 100% - 32px);
    margin: 0 auto;
    /* 全タブ共通: 左バー＋メインの上端を同じだけ下げ、タブ切替で縦位置が変わらないようにする */
    padding: 28px 16px 0;
    box-sizing: border-box;
}

.profile-layout > .profile-sidebar {
    flex: 0 0 auto;
    width: min(320px, 100%);
    min-width: 260px;
    max-width: 320px;
    align-self: flex-start;
}

.profile-layout > .profile-main {
    flex: 1 1 0;
    min-width: 0;
    align-self: flex-start;
}

/* 他ユーザービュー等でサイドバー無し・main のみ */
.profile-layout > .profile-main:only-child {
    flex: 1 1 100%;
    width: 100%;
    max-width: 100%;
}

@media (min-width: 1401px) {
    .profile-layout {
        max-width: 1400px;
    }
}

/* 左サイドバー（sticky 廃止: DM 等でタブごとに縦位置がズレるため通常フロー。長いメニューはページと一緒にスクロール） */
.profile-sidebar {
    width: 100%;
    min-width: 260px;
    background: var(--color-surface);
    border-radius: 16px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    padding: 30px 20px;
    position: relative;
    top: auto;
    max-height: none;
    overflow-x: visible;
    overflow-y: visible;
    height: auto;
    min-height: fit-content;
}

.profile-sidebar-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

/* プロフィール画像 */
.profile-image-container {
    width: 100%;
    display: flex;
    justify-content: center;
}

.profile-image-wrapper {
    position: relative;
    width: 150px;
    height: 150px;
}

.profile-sidebar-image {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--color-primary);
    box-shadow: 0 4px 15px rgba(var(--color-primary-rgb), 0.3);
}

/* デフォルトアイコン（data URI SVG）の青固定を避け、季節テーマで塗る */
.profile-sidebar-image[data-is-placeholder="1"] {
    background: var(--gradient-primary);
}

.profile-image-edit-btn {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--color-primary);
    border: 3px solid white;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.profile-image-edit-btn:hover {
    background: var(--color-primary-strong);
    transform: scale(1.1);
}

.profile-image-edit-btn svg {
    width: 20px;
    height: 20px;
}

/* ユーザー名 */
.profile-sidebar-name {
    font-size: 22px;
    font-weight: 700;
    color: var(--color-text);
    margin: 0;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 5px;
    line-height: 1.25;
}

.profile-sidebar-username {
    font-size: 14px;
    color: #666;
    margin: -10px 0 0 0;
    text-align: center;
}

/* フォロワー・フォロー中 */
.profile-sidebar-stats {
    display: flex;
    gap: 20px;
    width: 100%;
    justify-content: center;
    padding: 20px 0;
    border-top: 1px solid #e0e0e0;
    border-bottom: 1px solid #e0e0e0;
}

.sidebar-stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    transition: opacity 0.3s;
}

.sidebar-stat-item:hover {
    opacity: 0.7;
}

.sidebar-stat-item .stat-number {
    font-size: 20px;
    font-weight: 700;
    color: #333;
    line-height: 1;
}

.sidebar-stat-item .stat-label {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
}

/* サイドバーメニュー */
.profile-sidebar-menu {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.sidebar-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    text-decoration: none;
    color: #666;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.3s;
    position: relative;
}

.sidebar-menu-item:hover {
    background: #f5f5f5;
    color: var(--color-primary);
}

.sidebar-menu-item.active {
    background: var(--gradient-primary);
    color: white;
}

.sidebar-menu-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.menu-badge {
    margin-left: auto;
    background: rgba(255,255,255,0.3);
    color: inherit;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 600;
}

.sidebar-menu-item.active .menu-badge {
    background: rgba(255,255,255,0.4);
}

/* DM 未読：丸枠内に件数（① のイメージ） */
.menu-badge.dm-unread-menu-badge {
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
    background: linear-gradient(135deg, #ff6b9d 0%, #ff8e53 100%);
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.95);
    box-shadow: 0 2px 8px rgba(255, 107, 157, 0.35);
}

.sidebar-menu-item:not(.active) .menu-badge.dm-unread-menu-badge {
    background: var(--gradient-primary);
    border-color: rgba(var(--color-primary-rgb), 0.35);
    box-shadow: 0 2px 8px rgba(var(--color-primary-rgb), 0.25);
}

.sidebar-menu-item.active .menu-badge.dm-unread-menu-badge {
    background: rgba(255, 255, 255, 0.95);
    color: var(--color-primary-strong);
    border-color: rgba(255, 255, 255, 0.6);
    box-shadow: none;
}

/* プロフィール編集ボタン */
.profile-edit-sidebar-btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    background: var(--gradient-primary);
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s;
    margin-top: 10px;
}

.profile-edit-sidebar-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(var(--color-primary-rgb), 0.4);
}

.profile-edit-sidebar-btn svg {
    width: 18px;
    height: 18px;
}

.profile-edit-sidebar-btn.btn-following {
    background: #f5f5f5;
    color: #666;
    border: 2px solid #e0e0e0;
}

.profile-edit-sidebar-btn.btn-following:hover {
    background: #e8e8e8;
}

.profile-edit-sidebar-btn.btn-request-pending {
    background: white;
    color: #333;
    border: 2px solid #e0e0e0;
}

.profile-edit-sidebar-btn.btn-request-pending:hover {
    background: #f0f0f0;
    color: #333;
}

/* 右メインエリア */
.profile-main {
    flex: 1;
    min-width: 0;
    min-height: 300px;
    width: 100%;
}

/* タブ表示時はメイン内の表示タブが確実に幅を持つように */
.profile-main > .profile-tab-content.active,
.profile-main > [id^="tab-"].active {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.profile-main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.profile-main-title-row {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.profile-main-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--color-text);
    margin: 0;
}

/* 視聴統計：PC/iPad向け「視聴状況システム」切替トグル */
.profile-stats-mode-toggle {
    display: none; /* JSで対象デバイスのみ表示 */
    align-items: center;
    gap: 10px;
    user-select: none;
}
.profile-stats-mode-toggle .toggle-label {
    font-size: 13px;
    font-weight: 700;
    color: rgba(0, 0, 0, 0.65);
    white-space: nowrap;
}
.profile-stats-mode-toggle .toggle-switch {
    position: relative;
    width: 46px;
    height: 26px;
    border-radius: 999px;
    border: 1px solid rgba(var(--color-primary-rgb), 0.35);
    background: rgba(var(--color-primary-rgb), 0.14);
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
    flex: 0 0 auto;
}
.profile-stats-mode-toggle .toggle-switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
    transition: transform 0.2s ease;
}
.profile-stats-mode-toggle label {
    position: relative;
    display: inline-flex;
    align-items: center;
}
.profile-stats-mode-toggle input[type="checkbox"] {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
    opacity: 0 !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    pointer-events: none;
}
.profile-stats-mode-toggle input[type="checkbox"]:checked + .toggle-switch {
    background: rgba(var(--color-primary-rgb), 0.32);
    border-color: rgba(var(--color-primary-rgb), 0.55);
}
.profile-stats-mode-toggle input[type="checkbox"]:checked + .toggle-switch::after {
    transform: translateX(20px);
}
.profile-stats-mode-toggle input[type="checkbox"]:focus-visible + .toggle-switch {
    outline: 2px solid rgba(var(--color-primary-rgb), 0.55);
    outline-offset: 2px;
}
@media (max-width: 767px) {
    /* スマホは一切変えない：トグルを出さない */
    .profile-stats-mode-toggle { display: none !important; }
}

.customize-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    background: var(--gradient-primary);
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
}

.customize-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(var(--color-primary-rgb), 0.4);
}

.customize-btn svg {
    width: 18px;
    height: 18px;
}

/* プロフィールタブコンテンツ */
.profile-tab-content {
    display: none;
}

.profile-tab-content.active {
    display: block !important;
    min-height: 200px;
    visibility: visible !important;
    opacity: 1 !important;
}

/* タブ切り替え時に確実に表示（JSでactiveを付与した場合の保険） */
#tab-overview.active,
#tab-mylist.active,
#tab-statistics.active,
#tab-dm.active,
#tab-image-creator.active,
#tab-account.active {
    display: block !important;
    min-height: 200px;
}

#tab-statistics {
    min-width: 0;
    overflow-x: hidden;
}

/* カスタマイズ可能エリア */
.profile-customizable-area {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.empty-customize-state {
    background: white;
    border-radius: 16px;
    padding: 60px 40px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.empty-customize-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.empty-customize-state h3 {
    font-size: 22px;
    font-weight: 600;
    color: #333;
    margin: 0 0 10px 0;
}

.empty-customize-state p {
    font-size: 14px;
    color: #666;
    margin: 0 0 25px 0;
}

/* プロフィールセクション（内容に合わせて枠を下に伸ばす） */
.profile-section {
    background: var(--color-surface);
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    position: relative;
    min-width: 0;
    overflow: visible;
}

.profile-section.editable {
    border: 2px dashed transparent;
    transition: border-color 0.3s;
}

.profile-section.editable:hover {
    border-color: var(--color-primary);
}

.section-title {
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 20px 0;
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-actions {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 8px;
}

.section-action-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: none;
    background: #f5f5f5;
    color: #666;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.section-action-btn:hover {
    background: #e8e8e8;
    color: #333;
}

.section-action-btn svg {
    width: 16px;
    height: 16px;
}

/* アニメギャラリー */
.anime-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 20px;
}

.anime-gallery-item {
    position: relative;
    aspect-ratio: 3/4;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.anime-gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.anime-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.anime-gallery-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    padding: 15px;
    color: white;
    transform: translateY(100%);
    transition: transform 0.3s;
}

.anime-gallery-item:hover .anime-gallery-overlay {
    transform: translateY(0);
}

.anime-gallery-overlay h3 {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 5px 0;
    line-height: 1.3;
}

.anime-gallery-overlay p {
    font-size: 12px;
    margin: 0;
    opacity: 0.9;
}

/* TOP 10バッジ */
.top10-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 30px;
    height: 30px;
    background: var(--color-primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* キャラクターギャラリー */
.characters-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 20px;
}

.character-item {
    text-align: center;
}

.character-item img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #e0e0e0;
    margin-bottom: 10px;
    transition: border-color 0.3s;
}

.character-item:hover img {
    border-color: var(--color-primary);
}

.character-item h3 {
    font-size: 14px;
    font-weight: 500;
    margin: 0;
    color: #333;
}

/* 統計カード */
.statistics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    transition: transform 0.3s;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.stat-icon {
    font-size: 32px;
    margin-bottom: 10px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #333;
    margin-bottom: 8px;
}

.stat-label {
    font-size: 14px;
    color: #666;
}

/* マイリストセクション（統計タブの視聴状況別を含む） */
.mylist-section {
    background: white;
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    min-width: 0;
    overflow-x: hidden;
}

.mylist-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    flex-wrap: wrap;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 15px;
}

.mylist-tab {
    padding: 10px 20px;
    background: #f5f5f5;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #666;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
}

.mylist-tab:hover {
    background: #e8e8e8;
}

.mylist-tab.active {
    background: var(--gradient-primary);
    color: white;
}

.mylist-tab .count-badge {
    background: rgba(255,255,255,0.3);
    color: inherit;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 600;
}

.mylist-tab.active .count-badge {
    background: rgba(255,255,255,0.4);
}

.mylist-tab-pane {
    display: none;
}

.mylist-tab-pane.active {
    display: block;
}

/* 統計・マイリスト内：視聴状況別は約5列。ポスターは切らず contain（カード幅に合わせて縮小） */
#tab-statistics .anime-cards,
#tab-mylist .anime-cards,
.mylist-section .anime-cards {
    min-width: 0;
    gap: 10px;
    padding: 16px 0;
    grid-template-columns: repeat(5, minmax(0, 1fr));
}
#tab-statistics .anime-cards .anime-card,
#tab-mylist .anime-cards .anime-card,
.mylist-section .anime-cards .anime-card {
    min-width: 0;
}
#tab-statistics .anime-card-image,
#tab-mylist .anime-card-image,
.mylist-section .anime-card-image {
    height: auto;
    min-height: 0;
    max-height: clamp(120px, 18vw, 190px);
    aspect-ratio: 2 / 3;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #f0f2f6 0%, #e6e9f0 100%);
    overflow: hidden;
}
#tab-statistics .anime-card-image img,
#tab-mylist .anime-card-image img,
.mylist-section .anime-card-image img {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    object-position: center center;
    display: block;
}

@media (max-width: 1024px) {
    #tab-statistics .anime-cards,
    #tab-mylist .anime-cards,
    .mylist-section .anime-cards {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 10px;
    }
}
@media (max-width: 768px) {
    #tab-statistics .anime-cards,
    #tab-mylist .anime-cards,
    .mylist-section .anime-cards {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
    }
}

/* 統計・マイリストの小さいカード：ステータスボタン右の余白を左（スコアとの隙間）と同幅に */
body .profile-main .anime-card .anime-card-content,
body #tab-statistics .anime-card .anime-card-content,
body #tab-mylist .anime-card .anime-card-content,
body .mylist-section .anime-card .anime-card-content {
    padding: 12px 4px 12px 8px !important; /* 上 右 下 左 */
}
#tab-statistics .anime-card .anime-title,
#tab-mylist .anime-card .anime-title,
.mylist-section .anime-card .anime-title {
    padding-left: 4px;
    padding-right: 4px;
}

/* スコアとステータスボタンを自然なバランスで横並びに（ボタン左の余白を確実に詰める） */
#tab-statistics .anime-card .anime-score-row,
#tab-mylist .anime-card .anime-score-row,
.mylist-section .anime-card .anime-score-row {
    flex-wrap: wrap;
    flex-direction: row;
    align-items: center;
    gap: 4px !important;
}
#tab-statistics .anime-card .anime-score-section,
#tab-mylist .anime-card .anime-score-section,
.mylist-section .anime-card .anime-score-section {
    flex: 0 0 auto !important;
    min-width: 0;
    width: min-content;
}
#tab-statistics .anime-card .anime-score,
#tab-mylist .anime-card .anime-score,
.mylist-section .anime-card .anime-score {
    padding: 8px 12px;
    padding-top: 12px;
    gap: 6px;
    font-size: 0.95em;
}
#tab-statistics .anime-card .anime-score-count-badge,
#tab-mylist .anime-card .anime-score-count-badge,
.mylist-section .anime-card .anime-score-count-badge {
    font-size: 10px;
    padding: 3px 8px;
}
#tab-statistics .anime-card .star-icon,
#tab-mylist .anime-card .star-icon,
.mylist-section .anime-card .star-icon {
    font-size: 18px;
}
#tab-statistics .anime-card .anime-score-value,
#tab-mylist .anime-card .anime-score-value,
.mylist-section .anime-card .anime-score-value {
    font-size: 16px;
    min-width: 32px;
}
#tab-statistics .anime-card .status-selector,
#tab-mylist .anime-card .status-selector,
.mylist-section .anime-card .status-selector {
    flex: 1 1 auto;
    min-width: 0;
}
#tab-statistics .anime-card .status-main-btn,
#tab-mylist .anime-card .status-main-btn,
.mylist-section .anime-card .status-main-btn {
    width: 100%;
    min-width: 44px;
    min-height: 44px;
    padding: 8px 14px;
    box-sizing: border-box;
}
#tab-statistics .anime-card .status-icon,
#tab-mylist .anime-card .status-icon,
.mylist-section .anime-card .status-icon {
    font-size: 18px;
}

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

/* 作成したマイリスト（カード一覧・クリックで中身） */
.profile-custom-mylist-wrap {
    margin-bottom: 32px;
}
.profile-mylist-all-row {
    margin-bottom: 16px;
}
.profile-mylist-all-btn {
    display: inline-block;
    padding: 10px 20px;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.profile-mylist-all-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(var(--color-primary-rgb), 0.4);
}
.profile-sub-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 16px;
}
.profile-custom-mylist-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}
.profile-custom-mylist-card {
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid #eee;
}
.profile-custom-mylist-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.12);
}
/* 表紙：2×2 最大4枚（従来レイアウト） */
.profile-custom-mylist-card-covers {
    width: 100%;
    flex: 0 0 auto;
    aspect-ratio: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    background: #f0f0f0;
}
.profile-custom-mylist-card-covers img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.profile-custom-mylist-card-covers .profile-custom-mylist-card-empty {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: #999;
}
.profile-custom-mylist-card-name {
    padding: 12px 14px;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.profile-custom-mylist-empty {
    color: #666;
    font-size: 14px;
    padding: 24px 0;
}
.profile-custom-mylist-empty-line2 {
    white-space: nowrap;
}

@media (max-width: 768px) {
    .profile-custom-mylist-empty-line2 {
        white-space: normal;
        display: inline;
    }
}
.profile-mylist-detail {
    margin-top: 16px;
}
.profile-mylist-detail.hidden {
    display: none !important;
}
.profile-mylist-detail-back {
    display: inline-block;
    margin-bottom: 16px;
    padding: 8px 14px;
    background: #f0f0f0;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    color: #333;
}
.profile-mylist-detail-back:hover {
    background: #e0e0e0;
}
.profile-mylist-detail-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 16px;
    display: block;
}
.profile-mylist-detail-animes {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}
@media (max-width: 1024px) {
    .profile-mylist-detail-animes {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}
@media (max-width: 768px) {
    .profile-mylist-detail-animes {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}
.profile-mylist-detail-anime-card {
    display: block;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transition: transform 0.2s, box-shadow 0.2s;
    text-decoration: none;
    color: inherit;
}
.profile-mylist-detail-anime-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.1);
}
.profile-mylist-detail-anime-card img {
    width: 100%;
    height: auto;
    max-height: clamp(130px, 22vw, 200px);
    aspect-ratio: 2 / 3;
    object-fit: contain;
    object-position: center;
    display: block;
    margin: 0 auto;
    background: linear-gradient(180deg, #f0f2f6 0%, #e6e9f0 100%);
}
.profile-mylist-detail-anime-title {
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 500;
    color: #333;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* モーダル */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 16px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.modal.show .modal-content {
    transform: scale(1);
}

.modal-large {
    max-width: 900px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    border-bottom: 1px solid #e0e0e0;
}

.modal-header h2 {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
    color: #333;
}

.modal-close {
    background: none;
    border: none;
    font-size: 32px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s;
}

.modal-close:hover {
    background: #f5f5f5;
    color: #333;
}

.modal-body {
    padding: 30px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    color: #333;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--color-primary);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
    text-decoration: none;
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(var(--color-primary-rgb), 0.4);
}

.btn-secondary {
    background: #f5f5f5;
    color: #333;
    border: 2px solid #e0e0e0;
}

.btn-secondary:hover {
    background: #e8e8e8;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 画像アップロード */
.image-upload-area {
    text-align: center;
}

.image-upload-preview {
    position: relative;
    width: 200px;
    height: 200px;
    margin: 0 auto 20px;
    border-radius: 50%;
    overflow: hidden;
    border: 4px solid #e0e0e0;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* バナー画像用：横長プレビュー 320×95（選択枠・本番と完全一致させるため border なし・content-box） */
.image-upload-preview-banner {
    box-sizing: content-box;
    width: 320px;
    height: 95px;
    border: none;
    border-radius: 8px;
}

/* ラッパー位置で表示範囲を決めるため、img はラッパーにぴったり fill（cover だと中心固定でずれる） */
.image-upload-preview-banner .image-upload-preview-inner img {
    object-fit: fill;
}

.image-upload-preview-banner .image-upload-placeholder {
    padding-top: 0;
}

.image-upload-preview-inner {
    position: absolute;
    top: 0;
    left: 0;
    overflow: hidden;
    /* width/height/left/top は JS で設定（上プレビューと下の円の範囲を一致させるため） */
}

.image-upload-preview-inner img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: fill;
}

.image-upload-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
}

.image-upload-preview img.show {
    display: block;
}

.image-upload-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #999;
    text-align: center;
    padding-top: 4px; /* テキストを視覚的に円の中央に */
}

.image-upload-placeholder.hide {
    display: none;
}

.image-upload-placeholder svg {
    width: 48px;
    height: 48px;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.image-upload-placeholder p {
    font-size: 14px;
    margin: 0;
    line-height: 1.4;
}

/* 表示位置の調整（プレビュー設定） */
.image-position-editor {
    display: none;
    margin: 16px 0 20px;
    padding: 12px 0;
    border-top: 1px solid #e8e8e8;
}

.image-position-editor.is-visible {
    display: block;
}

/* バナー用：横長の矩形＝表示枠と同じ形。left/top で左上を指定するため transform は使わない */
.image-positioner-banner .image-positioner-circle {
    left: 0;
    top: 0;
    transform: none;
    border-radius: 4px;
    border: 2px solid rgba(255, 255, 255, 0.85);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
    background: transparent;
}
.image-positioner-banner .image-positioner-circle:hover,
.image-positioner-banner .image-positioner-circle:focus {
    border-color: rgba(255, 255, 255, 1);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.5);
}

.image-position-editor-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin: 0 0 4px;
}

.image-position-editor-desc {
    font-size: 12px;
    color: #666;
    margin: 0 0 12px;
}

.image-positioner {
    position: relative;
    width: 100%;
    max-width: 280px;
    aspect-ratio: 4 / 3;
    margin: 0 auto;
    border-radius: 8px;
    overflow: hidden;
    background: #2a2a2a;
    border: 1px solid #444;
}

.image-positioner-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center center;
    display: block;
    pointer-events: none;
}

/* 円の外を暗くして、表示されない部分をわかりやすく */
.image-positioner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 1;
}

.image-positioner-circle {
    position: absolute;
    width: 64px;
    height: 64px;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    border: 3px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.3);
    background: transparent;
    cursor: move;
    cursor: grab;
    touch-action: none;
    z-index: 2;
    transition: box-shadow 0.15s ease;
}

.image-positioner-circle:active {
    cursor: grabbing;
}

.image-positioner-circle:hover {
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.6);
}

.image-positioner-circle:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.5);
}

.image-upload-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* カスタマイズパネル */
.customize-panel {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 30px;
}

.customize-available h3,
.customize-preview h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 15px 0;
    color: #333;
}

.customize-elements {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.customize-element-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px;
    background: #f5f5f5;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: left;
}

.customize-element-btn:hover {
    background: #e8e8e8;
    border-color: var(--color-primary);
    transform: translateX(5px);
}

.element-icon {
    font-size: 24px;
}

.element-name {
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.customize-layout {
    min-height: 400px;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 8px;
    border: 2px dashed #e0e0e0;
}

.customize-section-item {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    cursor: move;
    transition: all 0.3s;
}

.customize-section-item:hover {
    border-color: var(--color-primary);
    box-shadow: 0 2px 8px rgba(var(--color-primary-rgb), 0.2);
}

.customize-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-name {
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.section-remove-btn {
    background: #f44336;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.section-remove-btn:hover {
    background: #d32f2f;
    transform: scale(1.1);
}

.customize-actions {
    margin-top: 20px;
    display: flex;
    justify-content: flex-end;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #999;
    font-size: 14px;
}

/* レスポンシブ */
@media (max-width: 1024px) {
    .profile-layout {
        flex-direction: column;
    }

    .profile-layout > .profile-sidebar {
        width: 100%;
        max-width: none;
        min-width: 0;
    }

    .profile-layout > .profile-main {
        flex: 1 1 auto;
        width: 100%;
    }
    
    .profile-sidebar {
        width: 100%;
        min-width: 0;
        position: static;
        max-height: none;
    }
    
    .profile-sidebar-content {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .profile-sidebar-stats {
        border: none;
        padding: 0;
    }
    
    .profile-sidebar-menu {
        flex-direction: row;
        flex-wrap: wrap;
        width: 100%;
    }
    
    .customize-panel {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .profile-page-new {
        --profile-page-pad-top: 20px;
        padding: var(--profile-page-pad-top) 0;
    }
    
    .profile-layout {
        padding: 20px 15px 0;
        gap: 20px;
    }
    
    .profile-sidebar {
        padding: 20px 15px;
    }
    
    .profile-main-title {
        font-size: 22px;
    }
    
    .anime-gallery {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 15px;
    }
    
    .anime-list-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
    }
    
    .statistics-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }
    
    .modal-content {
        margin: 10px;
    }
}

/* プロフィール内の DM（.dm-embed）：単体 dm.php 用の上余白・max-width 中央寄せを無効化し、左サイドバー＋メイン列の位置を他タブと揃える */
.profile-main .dm-page.dm-embed {
    padding: 0 !important;
    margin: 0 !important;
    max-width: none !important;
    width: 100%;
    box-sizing: border-box;
}

.profile-main .dm-page.dm-embed .dm-layout {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* ---------- DM タブ: 横幅を広げ、チャットを画面に近いサイズで表示（左リスト＋右会話） ---------- */
body[data-active-profile-tab="dm"] .profile-page-new .profile-layout {
    width: 100%;
    max-width: min(1720px, calc(100vw - 20px));
    margin-left: auto;
    margin-right: auto;
    padding-left: 10px;
    padding-right: 10px;
    box-sizing: border-box;
}

@media (min-width: 1401px) {
    body[data-active-profile-tab="dm"] .profile-page-new .profile-layout {
        max-width: min(1720px, calc(100vw - 24px));
    }
}

body[data-active-profile-tab="dm"] .profile-main .profile-main-header {
    margin-bottom: 12px;
}

body[data-active-profile-tab="dm"] .profile-main .dm-page.dm-embed .dm-layout {
    display: grid;
    grid-template-columns: minmax(260px, 34%) minmax(0, 1fr);
    gap: 0;
    align-items: stretch;
    width: 100%;
    /* ヘッダー・マイページ余白・「DM」見出し分を差し引き、チャットを縦に広く */
    height: calc(100dvh - 188px);
    min-height: min(520px, calc(100dvh - 188px));
    max-height: calc(100dvh - 140px);
}

/* dvh 非対応ブラウザ向けフォールバック */
@supports not (height: 100dvh) {
    body[data-active-profile-tab="dm"] .profile-main .dm-page.dm-embed .dm-layout {
        height: calc(100vh - 188px);
        min-height: min(520px, calc(100vh - 188px));
        max-height: calc(100vh - 140px);
    }
}

body[data-active-profile-tab="dm"] .profile-main .dm-page.dm-embed .dm-thread-list,
body[data-active-profile-tab="dm"] .profile-main .dm-page.dm-embed .dm-conversation {
    min-height: 0;
    height: 100%;
    max-height: 100%;
    box-sizing: border-box;
}

body[data-active-profile-tab="dm"] .profile-main .dm-page.dm-embed .dm-thread-list {
    border-radius: 14px 0 0 14px;
    border-right: 1px solid #e4e4ef;
    display: flex;
    flex-direction: column;
}

body[data-active-profile-tab="dm"] .profile-main .dm-page.dm-embed .dm-conversation {
    border-radius: 0 14px 14px 0;
    display: flex;
    flex-direction: column;
}

body[data-active-profile-tab="dm"] .profile-main .dm-page.dm-embed .dm-thread-items {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

body[data-active-profile-tab="dm"] .profile-main .dm-page.dm-embed .dm-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 18px 12px 14px;
    box-sizing: border-box;
}

/* 広い画面では吹き出しも少し読みやすく */
body[data-active-profile-tab="dm"] .profile-main .dm-page.dm-embed .dm-msg-wrap-mine .dm-message.mine {
    max-width: min(560px, 85%);
}
body[data-active-profile-tab="dm"] .profile-main .dm-page.dm-embed .dm-msg-wrap-other .dm-message.other {
    max-width: min(560px, calc(85% - 48px));
}

@media (max-width: 960px) {
    body[data-active-profile-tab="dm"] .profile-page-new .profile-layout {
        max-width: 100%;
        padding-left: 8px;
        padding-right: 8px;
    }
    body[data-active-profile-tab="dm"] .profile-main .dm-page.dm-embed .dm-layout {
        height: auto;
        min-height: 65dvh;
        max-height: none;
        grid-template-columns: 1fr;
        gap: 12px;
    }
    body[data-active-profile-tab="dm"] .profile-main .dm-page.dm-embed .dm-thread-list {
        border-radius: 14px;
        border-right: none;
        max-height: 42dvh;
    }
    body[data-active-profile-tab="dm"] .profile-main .dm-page.dm-embed .dm-conversation {
        border-radius: 14px;
        min-height: 48dvh;
    }
}

/* 単体 dm.php 用の min-height:560px は行全体を押し広げ左バーとの縦バランスを崩すため、プロフィール内は上記 DM タブ用で制御 */
.profile-main .dm-page.dm-embed .dm-thread-list,
.profile-main .dm-page.dm-embed .dm-conversation {
    min-height: 0;
}

/* プロフィール内アニメカード：ステータスボタン右余白を最小化（ファイル末尾で確実に適用） */
body .profile-main .anime-card .anime-card-content {
    padding-right: 4px !important;
}

/* 他ユーザーのプロフィール閲覧：カスタマイズ可能エリアのみ表示（サイドバーなし） */
.profile-page-new.profile-page-other .profile-layout {
    display: block;
    max-width: 900px;
    margin: 0 auto;
}
.profile-page-new.profile-page-other .profile-main {
    width: 100%;
    max-width: 100%;
}
.profile-other-back {
    margin-bottom: 16px;
}
.profile-other-back-link {
    color: var(--color-primary);
    text-decoration: none;
    font-size: 14px;
}
.profile-other-back-link:hover {
    text-decoration: underline;
}

/* ===== Mobile optimization overrides (profile) ===== */
@media (max-width: 1024px) {
    .profile-layout {
        width: min(100%, 100% - 20px);
        gap: 14px;
        padding: 14px 10px 0;
    }

    .profile-layout > .profile-sidebar {
        width: 280px;
        min-width: 240px;
        max-width: 280px;
    }
}

@media (max-width: 768px) {
    .profile-layout {
        flex-direction: column;
        width: 100%;
        padding: 10px 12px 0;
        gap: 12px;
    }

    .profile-layout > .profile-sidebar,
    .profile-layout > .profile-main {
        width: 100%;
        min-width: 0;
        max-width: 100%;
    }

    .profile-sidebar {
        padding: 16px 12px;
    }

    .profile-sidebar-menu {
        gap: 6px;
    }

    .sidebar-menu-item {
        padding: 10px 12px;
        font-size: 14px;
    }

    /* 視聴状況タブ：端に詰まりすぎないようグリッド化 */
    .mylist-section {
        padding: 20px 14px;
        box-sizing: border-box;
    }

    .mylist-tabs {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        padding-bottom: 4px;
    }

    .mylist-tab:nth-child(5) {
        grid-column: 1 / -1;
        justify-self: center;
        width: 100%;
        max-width: 320px;
    }

    /* 狭いカードで右端が潰れてステータスと重なるのを防ぐ */
    body .profile-main .anime-card .anime-card-content,
    body #tab-statistics .anime-card .anime-card-content,
    body #tab-mylist .anime-card .anime-card-content,
    body .mylist-section .anime-card .anime-card-content {
        padding-left: 8px !important;
        padding-right: 8px !important;
    }
}

/* スマホ：TOPと同様に3列・ポスターは切らず contain */
@media (max-width: 768px) {
    #tab-statistics .anime-cards,
    #tab-mylist .anime-cards,
    .mylist-section .anime-cards {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
        gap: 8px !important;
    }

    #tab-statistics .anime-card-image,
    #tab-mylist .anime-card-image,
    .mylist-section .anime-card-image {
        height: auto !important;
        min-height: 0 !important;
        aspect-ratio: 2 / 3;
        flex: 0 0 auto !important;
        max-height: 150px;
    }

    #tab-statistics .anime-card-image img,
    #tab-mylist .anime-card-image img,
    .mylist-section .anime-card-image img {
        object-fit: contain !important;
        object-position: center center;
        background: linear-gradient(180deg, #f0f2f6 0%, #e6e9f0 100%);
    }

    /* マイリスト統計のカード：ステータスを評価の横に（width:100% 解除） */
    #tab-statistics .anime-card .anime-score-section,
    #tab-mylist .anime-card .anime-score-section,
    .mylist-section .anime-card .anime-score-section {
        flex: 1 1 auto !important;
        width: auto !important;
        min-width: 0 !important;
    }

    #tab-statistics .anime-card .anime-score,
    #tab-mylist .anime-card .anime-score,
    .mylist-section .anime-card .anime-score {
        padding: 6px 6px 6px 8px !important;
        padding-top: 11px !important;
        gap: 4px !important;
    }

    #tab-statistics .anime-card .anime-score-count-badge,
    #tab-mylist .anime-card .anime-score-count-badge,
    .mylist-section .anime-card .anime-score-count-badge {
        font-size: 8px !important;
        padding: 2px 5px !important;
    }

    #tab-statistics .anime-card .star-icon,
    #tab-mylist .anime-card .star-icon,
    .mylist-section .anime-card .star-icon {
        font-size: 15px !important;
    }

    #tab-statistics .anime-card .anime-score-value,
    #tab-mylist .anime-card .anime-score-value,
    .mylist-section .anime-card .anime-score-value {
        font-size: 14px !important;
        min-width: 28px !important;
    }

    #tab-statistics .anime-card .status-selector,
    #tab-mylist .anime-card .status-selector,
    .mylist-section .anime-card .status-selector {
        flex: 0 0 auto !important;
    }

    #tab-statistics .anime-card .status-main-btn,
    #tab-mylist .anime-card .status-main-btn,
    .mylist-section .anime-card .status-main-btn {
        width: auto !important;
        max-width: 52px !important;
        min-height: auto !important;
        padding: 3px 4px !important;
    }

    #tab-statistics .anime-card .status-icon,
    #tab-mylist .anime-card .status-icon,
    .mylist-section .anime-card .status-icon {
        font-size: 14px !important;
    }
}

@media (max-width: 430px) {
    .profile-page-new {
        --profile-page-pad-top: 16px;
    }

    .profile-header-name {
        font-size: 20px;
    }

    .profile-header-info {
        padding: 0 12px 12px 12px;
    }

    .mylist-tabs {
        gap: 6px;
    }

    .mylist-tab {
        padding: 8px 10px;
        font-size: 12px;
        min-height: 40px;
    }
}

/* ===== Mobile redesign: own profile sidebar usability ===== */
@media (max-width: 768px) {
    .profile-page-new:not(.profile-page-other) {
        --profile-page-pad-top: 10px;
    }

    .profile-page-new:not(.profile-page-other) .profile-layout {
        padding: 8px 10px 0;
        gap: 10px;
    }

    .profile-page-new:not(.profile-page-other) .profile-sidebar {
        padding: 14px 12px 12px;
        border-radius: 18px;
        border: 1px solid #eceef8;
        box-shadow: 0 6px 22px rgba(22, 28, 54, 0.08);
    }

    .profile-page-new:not(.profile-page-other) .profile-sidebar-content {
        gap: 12px;
    }

    .profile-page-new:not(.profile-page-other) .profile-image-wrapper {
        width: 108px;
        height: 108px;
    }

    .profile-page-new:not(.profile-page-other) .profile-sidebar-image {
        width: 108px;
        height: 108px;
        border-width: 3px;
    }

    .profile-page-new:not(.profile-page-other) .profile-image-edit-btn {
        width: 36px;
        height: 36px;
    }

    .profile-page-new:not(.profile-page-other) .profile-sidebar-name {
        font-size: clamp(1.7rem, 7.2vw, 2.15rem);
        line-height: 1.2;
        text-align: center;
        overflow-wrap: anywhere;
    }

    .profile-page-new:not(.profile-page-other) .profile-sidebar-username {
        margin-top: -4px;
        font-size: 15px;
    }

    .profile-page-new:not(.profile-page-other) .profile-sidebar-stats {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
        width: 100%;
        padding: 2px 0 0;
        border: none;
    }

    .profile-page-new:not(.profile-page-other) .sidebar-stat-item {
        border-radius: 12px;
        padding: 10px 6px 9px;
        min-height: 66px;
        background: #f7f8ff;
        border: 1px solid #e8ebfb;
    }

    .profile-page-new:not(.profile-page-other) .sidebar-stat-item .stat-number {
        font-size: 28px;
        line-height: 1;
    }

    .profile-page-new:not(.profile-page-other) .sidebar-stat-item .stat-label {
        margin-top: 6px;
        font-size: 11px;
    }

    .profile-page-new:not(.profile-page-other) .profile-edit-sidebar-btn {
        width: 100%;
        min-height: 48px;
        margin-top: 2px;
        border-radius: 12px;
        font-size: 16px;
        order: 4;
    }

    .profile-page-new:not(.profile-page-other) .profile-sidebar-menu {
        order: 5;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
        margin-top: 0;
    }

    .profile-page-new:not(.profile-page-other) .sidebar-menu-item {
        min-height: 74px;
        padding: 10px 6px;
        border-radius: 12px;
        border: 1px solid var(--color-border);
        background: #fff;
        color: var(--color-text-muted);
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 7px;
        text-align: center;
        font-size: 12px;
        font-weight: 700;
        line-height: 1.25;
    }

    .profile-page-new:not(.profile-page-other) .sidebar-menu-item:hover {
        transform: none;
        background: var(--color-surface-strong);
        color: var(--color-primary-strong);
    }

    .profile-page-new:not(.profile-page-other) .sidebar-menu-item.active {
        border-color: transparent;
        background: var(--gradient-primary);
        color: #fff;
        box-shadow: 0 8px 18px rgba(var(--color-primary-rgb), 0.28);
    }

    .profile-page-new:not(.profile-page-other) .sidebar-menu-item svg {
        width: 18px;
        height: 18px;
    }

    .profile-page-new:not(.profile-page-other) .sidebar-menu-item .menu-badge:not(.dm-unread-menu-badge) {
        display: none !important;
    }

    .profile-page-new:not(.profile-page-other) .sidebar-menu-item .menu-badge.dm-unread-menu-badge {
        position: absolute;
        top: 6px;
        right: 6px;
        margin: 0;
        min-width: 18px;
        height: 18px;
        padding: 0 4px;
        font-size: 10px;
        border-width: 1.5px;
    }

    .profile-page-new:not(.profile-page-other) .profile-main {
        min-height: 0;
    }

    .profile-page-new:not(.profile-page-other) .profile-main-header {
        margin-bottom: 14px;
        padding-top: 2px;
    }

    .profile-page-new:not(.profile-page-other) .profile-main-title {
        font-size: clamp(1.45rem, 6vw, 1.9rem);
        line-height: 1.2;
    }
}

@media (max-width: 430px) {
    .profile-page-new:not(.profile-page-other) .profile-sidebar {
        padding: 12px 10px 10px;
    }

    .profile-page-new:not(.profile-page-other) .profile-image-wrapper,
    .profile-page-new:not(.profile-page-other) .profile-sidebar-image {
        width: 100px;
        height: 100px;
    }

    .profile-page-new:not(.profile-page-other) .profile-sidebar-name {
        font-size: clamp(1.55rem, 8vw, 2rem);
    }

    .profile-page-new:not(.profile-page-other) .profile-sidebar-menu {
        gap: 7px;
    }

    .profile-page-new:not(.profile-page-other) .sidebar-menu-item {
        min-height: 70px;
        padding: 9px 6px;
        font-size: 11px;
    }

    .profile-page-new:not(.profile-page-other) .profile-main-title {
        font-size: clamp(1.35rem, 6.8vw, 1.7rem);
    }
}
