.profile-page {
    max-width: 1180px;
    margin: 0 auto;
    padding: calc(76px + 32px) 5vw 90px;
    display: flex;
    flex-direction: column;
    gap: 34px;
}


#profileSignedIn,
#profilePublic {
    display: flex;
    flex-direction: column;
    gap: 34px;
}

#profileSignedIn[hidden],
#profilePublic[hidden] {
    display: none;
}


.kg-guest {
    max-width: 480px;
    margin: 12vh auto;
    text-align: center;
    padding: 40px 30px;
    background: var(--grad-card);
    border: 1px solid var(--line);
    border-radius: 18px;
}

.kg-guest-badge {
    width: 64px;
    height: 64px;
    margin: 0 auto 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(212, 175, 55, 0.18), transparent 70%);
    border: 1px solid var(--gold-dim);
}

.kg-guest h1 {
    font-size: clamp(24px, 3vw, 32px);
    margin-bottom: 10px;
}

.kg-guest p {
    color: var(--cream-dim);
    line-height: 1.6;
    margin-bottom: 22px;
}

.profile-sigin-btn {
    padding: 14px 30px;
    border: none;
    border-radius: 6px;
    background: linear-gradient(135deg, var(--gold), var(--gold-dim));
    color: var(--void);
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    font-size: 13px;
    cursor: pointer;
    transition: transform .2s, box-shadow .2s;
}
.profile-sigin-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(212, 175, 55, 0.25); }

/* ---------- Hero ---------- */
.kg-hero {
    position: relative;
    border-radius: 22px;
    overflow: hidden;
    padding: 56px 24px 40px;
    text-align: center;
    border: 1px solid var(--line);
    isolation: isolate;
}

.kg-hero-bg {
    position: absolute;
    inset: 0;
    background: var(--grad-hero);
    z-index: -1;
}
.kg-hero-bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center top, rgba(212, 175, 55, 0.10), transparent 60%);
}

.kg-hero-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.kg-avatar-wrap {
    position: relative;
    margin-bottom: 14px;
}

.kg-avatar {
    width: 108px;
    height: 108px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 44px;
    letter-spacing: 0.02em;
    color: var(--cream);
    background: linear-gradient(160deg, var(--burgundy), var(--card));
    border: 2.5px solid var(--gold);
    box-shadow: 0 0 0 6px rgba(212, 175, 55, 0.08), 0 12px 34px rgba(0, 0, 0, 0.5);
}


.kg-avatar.has-image {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.kg-name {
    max-width: 100%;
    font-size: clamp(30px, 4vw, 46px);
    margin: 2px 0 0;
    overflow-wrap: anywhere;
}

.kg-username {
    max-width: 100%;
    color: var(--cream-dim);
    font-size: 14px;
    margin-bottom: 6px;
    overflow-wrap: anywhere;
}

.kg-tagline {
    color: var(--gold-dim);
    font-size: 12.5px;
    letter-spacing: 0.02em;
    margin-bottom: 22px;
}

.kg-quickstats {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 22px;
}

.kg-quickstat {
    min-width: 120px;
    padding: 12px 18px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.kg-quickstat b { font-family: 'Bebas Neue', sans-serif; font-size: 24px; letter-spacing: 0.02em; }
.kg-quickstat > span { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--cream-dim); }
.kg-quickstat--soon { opacity: 0.55; }
.kg-quickstat--soon b { font-size: 18px; }

.kg-quickstat--coins {
    cursor: pointer;
    justify-content: center;
    transition: border-color .2s ease, transform .2s ease;
}
.kg-quickstat--coins b {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--gold);
    font-size: 30px;
}
.kg-quickstat--coins:hover,
.kg-quickstat--coins:focus-visible {
    border-color: var(--gold-dim);
    transform: translateY(-1px);
}
.kg-quickstat--coins:hover .kinocoin-icon,
.kg-quickstat--coins:focus-visible .kinocoin-icon {
    transform: translateY(-1px);
    filter: brightness(1.12) drop-shadow(0 0 3px rgba(212, 175, 55, 0.35));
}
.kg-quickstat--coins:hover .kinocoin::before,
.kg-quickstat--coins:focus-visible .kinocoin::before {
    opacity: 0.85;
    transform: scale(1.05);
}
.kg-quickstat--coins:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
    .kg-quickstat--coins:hover .kinocoin-icon,
    .kg-quickstat--coins:focus-visible .kinocoin-icon {
        transform: none;
    }
}



.kg-section-title {
    font-size: clamp(20px, 2.2vw, 26px);
    margin-bottom: 16px;
}

.kg-row-label {
    color: var(--cream-dim);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 18px 0 10px;
}


.kg-empty-card {
    text-align: center;
    padding: 44px 24px;
    border-radius: 18px;
    background: var(--grad-card);
    border: 1px solid var(--line);
}
.kg-empty-icon { font-size: 34px; margin-bottom: 12px; }
.kg-empty-card h2 { font-size: clamp(20px, 2.4vw, 28px); margin-bottom: 10px; }
.kg-empty-card p { color: var(--cream-dim); max-width: 460px; margin: 0 auto 20px; line-height: 1.6; }


.kg-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.kg-quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 14px;
}
.kg-qa-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 12px;
    border-radius: 12px;
    background: var(--card);
    border: 1px solid var(--line);
    color: var(--cream);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: transform .2s, border-color .2s;
}
.kg-qa-btn:hover { transform: translateY(-2px); border-color: var(--gold-dim); }

.kg-stat-card {
    position: relative;
    padding: 20px 16px;
    border-radius: 14px;
    background: var(--card);
    border: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: transform .2s, border-color .2s;
}
.kg-stat-card:hover { transform: translateY(-2px); border-color: var(--gold-dim); }
.kg-stat-icon { font-size: 20px; }
.kg-stat-card b { font-family: 'Bebas Neue', sans-serif; font-size: 30px; letter-spacing: 0.02em; }
.kg-stat-label { font-size: 12px; color: var(--cream-dim); text-transform: uppercase; letter-spacing: 0.04em; }



.kg-soon-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}
.kg-soon-card {
    position: relative;
    padding: 22px 20px 44px;
    border-radius: 16px;
    background: var(--grad-card);
    border: 1px solid var(--line);
}
.kg-soon-icon { font-size: 22px; }
.kg-soon-card h3 { font-size: 18px; margin: 10px 0 6px; font-family: 'Bebas Neue', sans-serif; letter-spacing: 0.03em; }
.kg-soon-card p { color: var(--cream-dim); font-size: 13px; line-height: 1.5; }
.kg-soon-card .kg-soon-tag { top: auto; bottom: 16px; left: 20px; right: auto; }


.kg-locked-panel {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 20px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed var(--line);
}
.kg-locked-panel--inline { margin-top: 16px; }
.kg-locked-icon { font-size: 20px; opacity: 0.7; }
.kg-locked-panel p { color: var(--cream-dim); font-size: 13.5px; line-height: 1.5; margin: 0; }



.activity-list {
    display: flex;
    flex-direction: column;
}
.activity-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 4px;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
    transition: background .15s;
}
.activity-row:last-child { border-bottom: none; }
.activity-row:hover { background: rgba(255, 255, 255, 0.02); }

.activity-avatar-link {
    flex: 0 0 auto;
    display: block;
    border-radius: 50%;
}
.activity-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    background-color: var(--card);
    border: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.activity-avatar-initial {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 15px;
    color: var(--cream-dim);
}

.activity-row-body {
    min-width: 0;
    flex: 1 1 auto;
}
.activity-row-text {
    color: var(--cream);
    font-size: 13.5px;
    line-height: 1.5;
    word-break: break-word;
}
.activity-row-icon { margin-right: 2px; }
.activity-row-time {
    color: var(--cream-dim);
    font-size: 11.5px;
    margin-top: 2px;
}

.activity-empty {
    color: var(--cream-dim);
    font-size: 13.5px;
    text-align: center;
    padding: 24px 0;
}

.activity-load-more {
    display: block;
    margin: 14px auto 0;
}

.activity-skeleton {
    display: flex;
    flex-direction: column;
}
.activity-skeleton[hidden],
.activity-load-more[hidden] {
    display: none;
}
.activity-skeleton-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 4px;
    border-bottom: 1px solid var(--line);
}
.activity-skeleton-row:last-child { border-bottom: none; }
.activity-skeleton-avatar {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(243, 237, 226, 0.06);
    animation: activity-skeleton-pulse 1.4s ease-in-out infinite;
}
.activity-skeleton-lines {
    min-width: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.activity-skeleton-line {
    height: 10px;
    max-width: 100%;
    border-radius: 5px;
    background: rgba(243, 237, 226, 0.06);
    animation: activity-skeleton-pulse 1.4s ease-in-out infinite;
}
@keyframes activity-skeleton-pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
    .activity-skeleton-avatar, .activity-skeleton-line { animation: none; }
}

.activity-empty {
    text-align: center;
    padding: 24px 4px;
}
.activity-empty p {
    margin: 0;
    color: var(--cream-dim);
    font-size: 13.5px;
}
.activity-empty p:first-child {
    color: var(--cream);
    font-size: 14px;
    margin-bottom: 4px;
}
.activity-empty-hint {
    line-height: 1.5;
}

.activity-error {
    text-align: center;
    padding: 20px 4px;
}
.activity-error p {
    margin: 0 0 10px;
    color: var(--cream-dim);
    font-size: 13.5px;
}
.activity-retry {
    display: inline-block;
}

.activity-end {
    text-align: center;
    color: var(--cream-dim);
    font-size: 12.5px;
    padding: 14px 0 2px;
    margin: 0;
}

.activity-sentinel {
    height: 1px;
}



.kg-taste-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 24px;
}

.kg-taste-subtitle {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--cream-dim);
    margin-bottom: 12px;
}

.kg-genre-bars { display: flex; flex-direction: column; gap: 12px; }
.kg-genre-bar-head {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    margin-bottom: 5px;
}
.kg-genre-bar-track {
    height: 8px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.06);
    overflow: hidden;
}
.kg-genre-bar-fill {
    height: 100%;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--crimson), var(--gold));
    transition: width .5s ease;
}

.kg-taste-facts {
    display: flex;
    flex-direction: column;
    gap: 10px;
    justify-content: center;
}
.kg-fact-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 10px;
    font-size: 13.5px;
}
.kg-fact-row b { font-family: 'Bebas Neue', sans-serif; font-size: 16px; letter-spacing: 0.02em; color: var(--gold); }

.kg-taste-empty {
    color: var(--cream-dim);
    font-size: 13px;
    padding: 10px 2px;
}


.kg-movie-row {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: thin;
}

.kg-movie-card {
    flex: 0 0 auto;
    width: 140px;
}

.kg-movie-poster {
    width: 140px;
    height: 200px;
    border-radius: 10px;
    background-size: cover;
    background-position: center;
    background-color: var(--card);
    border: 1px solid var(--line);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

.kg-movie-meta { padding-top: 8px; }
.kg-movie-title {
    font-size: 13px;
    line-height: 1.3;
    max-height: 2.6em;
    overflow: hidden;
    text-overflow: ellipsis;
}
.kg-movie-sub { font-size: 11.5px; color: var(--cream-dim); margin-top: 3px; }

.kg-edit-overlay {
    position: fixed;
    inset: 0;
    background: rgba(8, 6, 8, 0.72);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s;
    z-index: 200;
}
.kg-edit-overlay.open { opacity: 1; pointer-events: auto; }
.kg-edit-modal {
    position: relative;
    max-width: 400px;
    width: 90%;
    padding: 34px 28px;
    text-align: center;
    background: var(--grad-card);
    border: 1px solid var(--line);
    border-radius: 18px;
}
.kg-edit-modal h2 { font-size: 22px; margin-bottom: 10px; }
.kg-edit-modal p { color: var(--cream-dim); font-size: 13.5px; line-height: 1.6; }


.kg-edit-modal--form {
    max-width: 460px;
    text-align: left;
    max-height: 88vh;
    overflow-y: auto;
}
.kg-edit-modal--form h2 { text-align: center; }

.kg-edit-avatar-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin: 6px 0 22px;
}
.kg-edit-avatar {
    width: 88px;
    height: 88px;
    font-size: 34px;
    background-size: cover;
    background-position: center;
    cursor: pointer;
}
.kg-change-avatar-btn {
    background: none;
    border: none;
    color: var(--gold);
    font-size: 12.5px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    cursor: pointer;
    padding: 4px 8px;
}
.kg-change-avatar-btn:hover { text-decoration: underline; }

.kg-field { margin-bottom: 18px; }
.kg-field label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--gold-dim);
    margin-bottom: 7px;
}
.kg-field input[type="text"],
.kg-field textarea,
.kg-field select {
    width: 100%;
    padding: 11px 13px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--cream);
    font-family: inherit;
    font-size: 14px;
    resize: none;
    transition: border-color .2s;
}
.kg-field input[type="text"]:focus,
.kg-field textarea:focus,
.kg-field select:focus {
    outline: none;
    border-color: var(--gold-dim);
}
.kg-field-hint {
    font-size: 11.5px;
    color: var(--cream-dim);
    margin-top: 5px;
}
.kg-field-hint.error { color: var(--crimson, #b5333c); }
.kg-field-hint.ok { color: #6fbf73; }
.kg-char-count { text-align: right; }

.kg-genre-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.kg-genre-pill {
    padding: 7px 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--cream-dim);
    font-size: 12.5px;
    cursor: pointer;
    transition: all .15s;
    user-select: none;
}
.kg-genre-pill.selected {
    border-color: var(--gold);
    color: var(--void);
    background: linear-gradient(135deg, var(--gold), var(--gold-dim));
    font-weight: 700;
}
.kg-genre-pill.disabled { opacity: .4; cursor: not-allowed; }

.kg-edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 8px;
    position: sticky;
    bottom: -34px;
    background: var(--grad-card);
    padding-top: 10px;
}


.kg-avatar-picker-modal { max-width: 360px; text-align: center; }
.kg-avatar-current-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}
.kg-avatar-current-label {
    font-size: 12px;
    color: var(--gold-dim);
    letter-spacing: 0.03em;
}
.kg-avatar-option {
    display: block;
    width: 100%;
    text-align: center;
    padding: 13px;
    margin-bottom: 10px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--cream);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color .2s, background .2s;
    box-sizing: border-box;
}
.kg-avatar-option:hover { border-color: var(--gold-dim); }
.kg-avatar-option--upload { border-color: var(--gold-dim); color: var(--gold); }
.kg-avatar-option--danger { color: #d97070; }

/* ---------- Avatar crop ---------- */
.kg-crop-modal { max-width: 380px; text-align: center; }
.kg-crop-stage {
    width: 300px;
    height: 300px;
    max-width: 100%;
    margin: 10px auto 14px;
    border-radius: 50%;
    overflow: hidden;
    border: 2.5px solid var(--gold);
    touch-action: none;
    cursor: grab;
}
.kg-crop-stage:active { cursor: grabbing; }
#kgCropCanvas { width: 100%; height: 100%; display: block; }
.kg-crop-zoom { width: 90%; margin: 0 auto 4px; accent-color: var(--gold); }

@media (max-width: 480px) {
    .kg-edit-overlay { align-items: flex-end; }
    .kg-edit-modal { max-width: 100%; width: 100%; border-radius: 18px 18px 0 0; }
    .kg-edit-modal--form { max-height: 92vh; }
}


@media (max-width: 900px) {
    .kg-taste-grid { grid-template-columns: 1fr; }
}

@media (max-width: 767px) {
    .profile-page { padding: calc(60px + 20px) 5vw 70px; gap: 26px; }
    #profileSignedIn,
    #profilePublic { gap: 26px; }
    .kg-hero { padding: 40px 16px 30px; border-radius: 16px; }
    .kg-avatar { width: 88px; height: 88px; font-size: 36px; }
    .kg-stats-grid { grid-template-columns: repeat(2, 1fr); }
    .kg-quickstat { min-width: 100px; padding: 10px 14px; }
    .kg-quickstat--coins b { font-size: 26px; gap: 6px; }
    .kg-movie-card, .kg-movie-poster { width: 118px; }
    .kg-movie-poster { height: 168px; }
}

@media (prefers-reduced-motion: reduce) {
    .kg-stat-card, .profile-sigin-btn, .kg-genre-bar-fill, .kg-edit-overlay {
        transition: none !important;
    }
}

/* ================= PUBLIC PROFILE (?userId=) ================= */
.kg-public-back {
    position: absolute;
    top: 18px;
    left: 18px;
    font-size: 12px;
    z-index: 2;
}

.kg-public-bio {
    max-width: 480px;
    margin: 6px auto 0;
    color: var(--cream-dim);
    font-size: 13px;
    line-height: 1.5;
}

.kg-public-genre-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.kg-public-genre-chips .kg-genre-chip {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 12px;
    color: var(--cream);
}

.kg-public-resonance-card {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--gold-dim);
    border-radius: 14px;
    padding: 20px 24px;
}

.kg-public-resonance-pct {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 42px;
    color: var(--gold);
    line-height: 1;
}

.kg-public-resonance-msg {
    margin: 0;
    color: var(--cream-dim);
    font-size: 13px;
    line-height: 1.5;
}

@media (max-width: 767px) {
    .kg-public-back { position: static; display: inline-block; margin-bottom: 14px; }
    .kg-public-resonance-card { flex-direction: column; align-items: flex-start; }
}

.kg-follow-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-bottom: 18px;
}

.kg-follow-stat {
    min-width: 96px;
    padding: 10px 20px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 2px;
    cursor: pointer;
    color: inherit;
    font: inherit;
    transition: border-color .2s, transform .2s;
}
.kg-follow-stat:hover { border-color: var(--gold-dim); transform: translateY(-2px); }
.kg-follow-stat b { font-family: 'Bebas Neue', sans-serif; font-size: 22px; letter-spacing: 0.02em; }
.kg-follow-stat span { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--cream-dim); }

.kg-follow-btn { min-height: 42px; min-width: 150px; }
.kg-follow-btn.kg-follow-btn--following {
    background: transparent;
    color: var(--cream);
    border: 1px solid var(--gold-dim);
}
.kg-follow-btn.kg-follow-btn--following:hover {
    border-color: #d97070;
    color: #d97070;
}

/* Block 3 — Friend action button states. Layout of the whole action set
   lives in the "Profile Hero geometry" section at the end of this file. */
.kg-friend-btn { min-height: 42px; min-width: 150px; }
.kg-friend-btn--pending {
    background: transparent;
    color: var(--cream);
    border: 1px solid var(--gold-dim);
}
.kg-friend-btn--friends {
    background: transparent;
    color: var(--gold);
    border: 1px solid var(--gold);
}
.kg-friend-btn--friends:hover {
    border-color: #d97070;
    color: #d97070;
}

.kg-friend-decline-link {
    background: none;
    border: none;
    color: var(--cream-dim);
    font-size: 12px;
    text-decoration: underline;
    cursor: pointer;
    padding: 4px 2px;
}
.kg-friend-decline-link:hover { color: var(--cream); }
.kg-friend-decline-link:disabled { opacity: .5; cursor: default; }

/* Block 3.1 — Incoming/Sent tabs inside the Friend Requests modal. */
.kg-friend-requests-tabs {
    display: flex;
    gap: 6px;
    margin-top: 14px;
    border-bottom: 1px solid var(--line);
}

.kg-friend-requests-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--cream-dim);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 10px 12px;
    cursor: pointer;
    min-height: 38px;
}
.kg-friend-requests-tab:hover { color: var(--cream); }
.kg-friend-requests-tab.is-active {
    color: var(--gold);
    border-bottom-color: var(--gold);
}

/* Friend-request rows inside the Friend Requests modal reuse
   .kg-follow-list-item's avatar/name layout, replacing the followers-count
   text with Accept/Decline actions. */
.kg-friend-request-item { align-items: center; }
.kg-friend-request-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex: 0 0 auto;
}
.kg-friend-request-actions .btn-primary,
.kg-friend-request-actions .btn-ghost {
    min-height: 34px;
    padding: 0 12px;
    font-size: 12px;
}

@media (max-width: 480px) {
    .kg-friend-request-item {
        flex-wrap: wrap;
    }
    .kg-friend-request-actions {
        width: 100%;
        justify-content: flex-end;
        margin-top: 6px;
    }
}

.kg-follow-list-modal { max-width: 420px; text-align: left; }
.kg-follow-list {
    max-height: 60vh;
    overflow-y: auto;
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.kg-follow-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 6px;
    border-radius: 10px;
    text-decoration: none;
    color: inherit;
    transition: background .15s;
}
.kg-follow-list-item:hover { background: rgba(255, 255, 255, 0.04); }

.kg-follow-list-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    flex: 0 0 auto;
    background-size: cover;
    background-position: center;
    background: linear-gradient(160deg, var(--burgundy), var(--card));
    border: 1.5px solid var(--gold-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 16px;
}

.kg-follow-list-info { flex: 1 1 auto; min-width: 0; }
.kg-follow-list-name {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.kg-follow-list-username {
    font-size: 12px;
    color: var(--cream-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.kg-follow-list-followers {
    font-size: 11px;
    color: var(--gold-dim);
    flex: 0 0 auto;
    white-space: nowrap;
}

.kg-follow-list-empty {
    color: var(--cream-dim);
    font-size: 13.5px;
    text-align: center;
    padding: 30px 10px;
}

@media (max-width: 480px) {
    .kg-follow-stat { min-width: 84px; padding: 8px 14px; }
}

/* ==========================================================================
   BLOCK 10 — Achievements
   Same dark/cinematic/premium language as the rest of Profile: --card
   surfaces, --gold accents, no bright/acid colors. Rarity is communicated
   by a thin top border + tag color, not by a different card shape.
   ========================================================================== */

.kg-achievements-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}
.kg-achievements-head .kg-section-title { margin-bottom: 0; }

.kg-achievements-progress-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 180px;
}
.kg-achievements-progress-label {
    font-size: 12.5px;
    color: var(--cream-dim);
    white-space: nowrap;
}
.kg-achievements-progress-bar {
    flex: 1;
    height: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    overflow: hidden;
    min-width: 90px;
}
.kg-achievements-progress-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--gold-dim), var(--gold));
    transition: width 0.4s ease;
}

.kg-achievements-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.kg-ach-signin-btn {
    /* Global .btn-ghost (style.css) defaults to display:none below the
       768px breakpoint — same fix already applied for the equivalent
       sign-in-again buttons in kinorank.css/your-resonance.css/etc. */
    display: inline-flex;
    margin-top: 10px;
    font-size: 12px;
    padding: 8px 16px;
}

.kg-ach-recent-empty {
    color: var(--cream-dim);
    font-size: 13px;
    margin: 0 0 16px;
}

.kg-ach-recent-label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--cream-dim);
    margin-bottom: 8px;
}

.kg-ach-recent-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.kg-ach-recent-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--gold-dim);
    background: rgba(212, 175, 55, 0.06);
    font-size: 12px;
    color: var(--cream);
    max-width: 220px;
}

.kg-ach-recent-icon { font-size: 14px; line-height: 1; }

.kg-ach-recent-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.kg-ach-filter {
    padding: 7px 14px;
    border-radius: 999px;
    background: var(--card);
    border: 1px solid var(--line);
    color: var(--cream-dim);
    font-size: 12px;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: border-color .2s, color .2s;
    min-height: 32px;
}
.kg-ach-filter:hover { border-color: var(--gold-dim); color: var(--cream); }
.kg-ach-filter--active {
    background: rgba(212, 175, 55, 0.12);
    border-color: var(--gold);
    color: var(--gold);
}

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

.kg-ach-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-align: center;
    padding: 18px 12px 14px;
    border-radius: 14px;
    background: var(--card);
    border: 1px solid var(--line);
    border-top: 3px solid var(--gold-dim);
    color: var(--cream);
    cursor: pointer;
    transition: transform .2s, border-color .2s;
    min-height: 44px;
    font-family: inherit;
}
.kg-ach-card:hover { transform: translateY(-2px); border-color: var(--gold-dim); }

.kg-ach-card--locked { opacity: 0.6; }
.kg-ach-card--locked .kg-ach-icon { filter: grayscale(1); opacity: 0.7; }
.kg-ach-card--unlocked { opacity: 1; }

.kg-ach-icon { font-size: 30px; line-height: 1; }
.kg-ach-name {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
}
.kg-ach-rarity-tag {
    font-size: 9.5px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--cream-dim);
}

.kg-ach-progress {
    width: 100%;
    height: 5px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    overflow: hidden;
    margin-top: 4px;
}
.kg-ach-progress-fill {
    height: 100%;
    border-radius: 999px;
    background: var(--gold-dim);
}
.kg-ach-progress-label {
    font-size: 10.5px;
    color: var(--cream-dim);
}
.kg-ach-unlocked-badge {
    font-size: 10.5px;
    color: var(--gold);
    font-weight: 600;
    margin-top: 4px;
}

/* Rarity accents — top border + rarity tag color only, keeps the grid calm. */
.kg-ach-rarity--common     { border-top-color: var(--cream-dim); }
.kg-ach-rarity--uncommon   { border-top-color: #6fae7a; }
.kg-ach-rarity--uncommon .kg-ach-rarity-tag { color: #6fae7a; }
.kg-ach-rarity--rare       { border-top-color: #5b8fd6; }
.kg-ach-rarity--rare .kg-ach-rarity-tag { color: #5b8fd6; }
.kg-ach-rarity--epic       { border-top-color: var(--violet); }
.kg-ach-rarity--epic .kg-ach-rarity-tag { color: #a98bd6; }
.kg-ach-rarity--legendary  { border-top-color: var(--gold); }
.kg-ach-rarity--legendary .kg-ach-rarity-tag { color: var(--gold); }
.kg-ach-rarity--mythic     { border-top-color: var(--crimson-bright); box-shadow: 0 0 22px -6px rgba(200,32,58,0.45); }
.kg-ach-rarity--mythic .kg-ach-rarity-tag { color: var(--crimson-bright); }

/* ---------- Achievement detail modal ---------- */
.kg-achievement-modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 300;
    background: rgba(8, 5, 7, 0.72);
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.kg-achievement-modal-backdrop.open { display: flex; }
.kg-achievement-modal {
    position: relative;
    width: 100%;
    max-width: 360px;
    padding: 32px 26px 26px;
    border-radius: 18px;
    background: var(--grad-card);
    border: 1px solid var(--gold-dim);
    text-align: center;
    box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.7);
}
.kg-achievement-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: none;
    color: var(--cream-dim);
    font-size: 14px;
    cursor: pointer;
}
.kg-achievement-modal-close:hover { color: var(--cream); }
.kg-achievement-modal-icon { font-size: 46px; margin-bottom: 10px; }
.kg-achievement-modal-name {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 22px;
    letter-spacing: 0.02em;
    margin: 0 0 8px;
}
.kg-achievement-modal-desc {
    color: var(--cream-dim);
    font-size: 13.5px;
    line-height: 1.55;
    margin: 0 0 14px;
}
.kg-achievement-modal-rarity {
    display: inline-block;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 4px 12px;
    border-radius: 999px;
    background: rgba(212, 175, 55, 0.12);
    color: var(--gold);
    margin-bottom: 12px;
}
.kg-achievement-modal-progress {
    font-size: 13px;
    color: var(--cream);
    font-weight: 600;
}
.kg-achievement-modal-date {
    margin-top: 10px;
    font-size: 12px;
    color: var(--cream-dim);
}
.kg-achievement-modal-xp {
    display: inline-block;
    margin-top: 12px;
    font-size: 13px;
    font-weight: 700;
    color: var(--gold);
}

/* ---------- Compact profile rarity strip (Achievements 2.0) ---------- */
.kg-ach-rarity-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 10px 0;
}
.kg-ach-rarity-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    padding: 3px 9px;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--cream-dim);
    background: rgba(255,255,255,0.03);
}
.kg-ach-rarity-pill.kg-ach-rarity--rare       { color: #5b8fd6; border-color: #5b8fd6; }
.kg-ach-rarity-pill.kg-ach-rarity--epic       { color: #a98bd6; border-color: var(--violet); }
.kg-ach-rarity-pill.kg-ach-rarity--legendary  { color: var(--gold); border-color: var(--gold-dim); }
.kg-ach-rarity-pill.kg-ach-rarity--mythic     { color: var(--crimson-bright); border-color: var(--crimson); }

.kg-ach-viewall {
    font-size: 12.5px;
    color: var(--gold);
    text-decoration: none;
    white-space: nowrap;
}
.kg-ach-viewall:hover { text-decoration: underline; }

.ach-toast-xp {
    display: block;
    font-size: 11px;
    color: var(--gold);
    margin-top: 2px;
}

@media (max-width: 480px) {
    .kg-achievements-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
    .kg-ach-card { padding: 14px 8px 12px; }
    .kg-ach-icon { font-size: 26px; }
    .kg-ach-name { font-size: 12px; }
    .kg-achievements-head { flex-direction: column; align-items: flex-start; }
    .kg-achievements-progress-wrap { width: 100%; }
}

/* ==========================================================================
   Profile Hero geometry — stats + action grid (Own & Public Profile)
   --------------------------------------------------------------------------
   Quick stats, follow stats and the action buttons share one centered
   column (--kg-hero-col) so they read as a single vertical system:

       [ stat ][ stat ][ coins ]      <- .kg-quickstats
       [ followers ][ following ][ friends ]
       [ action      ][ action      ] <- .kg-hero-actions (2 equal columns)
       [ action      ][ action      ]

   One gap token (--kg-hero-gap) is used both inside and between the tiers.
   Layout switches are driven by the hero's own width (container queries),
   not by the viewport or a particular language.
   ========================================================================== */

.kg-hero-inner {
    --kg-hero-col: 480px;
    --kg-hero-gap: 10px;
    container: kg-hero / inline-size;
}

.kg-hero-inner > .kg-quickstats,
.kg-hero-inner > .kg-follow-stats,
.kg-hero-inner > .kg-hero-actions {
    width: min(100%, var(--kg-hero-col));
    box-sizing: border-box;
}

/* ---- Stats tiers ---------------------------------------------------- */
.kg-hero-inner > .kg-quickstats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--kg-hero-gap);
    /* .kg-hero-inner already adds 6px, so the two stat tiers sit exactly
       one --kg-hero-gap apart and read as one stats block. */
    margin-bottom: calc(var(--kg-hero-gap) - 6px);
}

/* Own profile: 3 tiles. The coins column never shrinks below its content,
   so a large KinoCoin balance widens that tile instead of overflowing it —
   it never changes the height of the block, so nothing below moves. */
#kgQuickstats {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(max-content, 1fr);
}

.kg-hero-inner > .kg-quickstats > .kg-quickstat,
.kg-hero-inner > .kg-follow-stats > .kg-follow-stat {
    min-width: 0;
}

#kgQuickstats > .kg-quickstat--coins {
    align-items: center;
}

/* Numbers stay on one line across a tier even when a label wraps. */
.kg-hero-inner > .kg-quickstats > .kg-quickstat:not(.kg-quickstat--coins) {
    justify-content: flex-start;
    padding: 12px 10px;
}

.kg-hero-inner .kg-quickstat > span,
.kg-hero-inner .kg-follow-stat span {
    text-wrap: balance;
}

.kg-hero-inner > .kg-follow-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--kg-hero-gap);
    margin-bottom: 0;
}

.kg-hero-inner > .kg-follow-stats > .kg-follow-stat {
    padding: 10px 12px;
}

/* ---- Action grid ---------------------------------------------------- */
.kg-hero-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--kg-hero-gap);
    align-items: stretch;
    margin-top: 12px;
}

/* [hidden] must win over the grid/flex display of the container and of
   .btn-ghost (display:inline-flex). Without it the Message button showed
   for non-friends and an empty Add-Friend box showed for signed-out
   visitors on the Public Profile. */
.kg-hero-actions[hidden],
.kg-hero-actions > [hidden] {
    display: none !important;
}

.kg-hero-actions > .kg-hero-action {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    max-width: none;
    min-height: 44px;
    margin: 0;
    padding: 10px 16px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: 0.1em;
    text-align: center;
    text-transform: uppercase;
    text-decoration: none;
    text-wrap: balance;
    white-space: normal;
    overflow-wrap: normal;
    cursor: pointer;
    touch-action: manipulation;
}

/* A lone last button (odd count) spans the full row instead of leaving a
   hole in the grid — e.g. Public Profile "Sign in", or Message under
   Follow + Friend. Hidden buttons are ignored when counting. */
.kg-hero-actions > .kg-hero-action:nth-child(odd of .kg-hero-action:not([hidden])):nth-last-child(1 of .kg-hero-action:not([hidden])) {
    grid-column: 1 / -1;
}

/* Secondary (KinoGrain ghost) — a light scrim keeps labels readable on
   bright cinematic backgrounds without changing the ghost look. */
.kg-hero-actions > .btn-ghost.kg-hero-action {
    background: rgba(10, 6, 8, 0.34);
}
.kg-hero-actions > .btn-ghost.kg-hero-action:hover {
    background: rgba(255, 255, 255, 0.08);
}

/* Primary (Public: Follow) keeps the crimson KinoGrain CTA; a transparent
   1px border gives it exactly the same box as the ghost buttons. */
.kg-hero-actions > .btn-primary.kg-hero-action:not(.kg-follow-btn--following) {
    border: 1px solid transparent;
}
.kg-hero-actions > .btn-primary.kg-follow-btn--following {
    background: rgba(10, 6, 8, 0.34);
    box-shadow: none;
}

/* Accent (Own: Customize profile) — moderate gold emphasis. */
.kg-hero-actions > .btn-ghost.kg-customize-btn {
    color: var(--gold);
    border-color: rgba(212, 175, 55, 0.5);
    background: rgba(212, 175, 55, 0.07);
}
.kg-hero-actions > .btn-ghost.kg-customize-btn:hover {
    border-color: var(--gold);
    background: rgba(212, 175, 55, 0.13);
}

.kg-hero-actions > .kg-hero-action:focus-visible,
.kg-hero-actions > .kg-friend-decline-link:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

.kg-hero-actions > .kg-hero-action:disabled {
    opacity: 0.55;
    cursor: default;
}

/* Icon + label are centered as one group (Invite). */
.kg-hero-action-icon {
    flex: none;
    font-size: 14px;
    line-height: 1;
    letter-spacing: 0;
}

/* Friend Requests: the badge is a corner notification indicator, taken out
   of the flow so showing/hiding it never changes the label position or the
   button size. Symmetric inline padding reserves its corner on both sides,
   keeping the label optically centered. */
.kg-hero-actions > .kg-friend-requests-btn {
    padding-inline: 30px;
}

.kg-friend-requests-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--crimson-bright, #d61f3c);
    box-shadow: 0 0 0 2px rgba(10, 6, 8, 0.85);
    color: #fff;
    font-size: 10.5px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0;
    pointer-events: none;
}
.kg-friend-requests-badge[hidden] {
    display: none;
}

/* Public Profile: "Decline" is a tertiary text action under Accept. */
.kg-hero-actions > .kg-friend-decline-link {
    grid-column: 1 / -1;
    justify-self: center;
    min-height: 32px;
    margin-top: -4px;
    padding: 4px 12px;
}

@media (prefers-reduced-motion: reduce) {
    .kg-hero-actions > .kg-hero-action {
        transition: none;
    }
    .kg-hero-actions > .btn-primary.kg-hero-action:hover {
        transform: none;
    }
}

/* ---- Narrow hero (phones) ------------------------------------------- */
@container kg-hero (max-width: 419px) {
    .kg-hero-inner {
        --kg-hero-gap: 8px;
    }

    /* Own profile: Rated + Average side by side, coins as a full-width tile
       beneath — no orphaned third tile. */
    #kgQuickstats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    #kgQuickstats > .kg-quickstat--coins {
        grid-column: 1 / -1;
    }

    .kg-hero-inner > .kg-quickstats > .kg-quickstat {
        padding: 10px 8px;
    }
    .kg-hero-inner > .kg-follow-stats > .kg-follow-stat {
        padding: 8px 4px;
    }
    .kg-hero-inner .kg-quickstat > span,
    .kg-hero-inner .kg-follow-stat span {
        letter-spacing: 0.03em;
    }

    .kg-hero-actions {
        margin-top: 10px;
    }
    .kg-hero-actions > .kg-hero-action {
        padding: 9px 10px;
        letter-spacing: 0.05em;
    }
    .kg-hero-actions > .kg-friend-requests-btn {
        padding-inline: 26px;
    }
}

/* Very narrow hero (≈320–360px phones): labels such as "Редактировать
   профиль" no longer fit two per row without breaking words, so the grid
   becomes a single column instead of shrinking the type. */
@container kg-hero (max-width: 299px) {
    .kg-hero-actions {
        grid-template-columns: minmax(0, 1fr);
    }
    .kg-hero-inner > .kg-follow-stats > .kg-follow-stat {
        padding-inline: 2px;
    }
    .kg-hero-inner .kg-follow-stat span {
        font-size: 10px;
        letter-spacing: 0;
    }
}
