/* Profile page styles. Shared branding stays in site-branding.css. */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Arial, Helvetica, sans-serif;
    color: white;
    background: radial-gradient( circle at 12% 15%, rgba(124,58,237,0.15), transparent 30% ), radial-gradient( circle at 88% 75%, rgba(32,201,187,0.12), transparent 30% ), linear-gradient( 135deg, #030609, #071018 48%, #04070c );
}

.top-header {
    width: 100%;
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 6%;
    position: sticky;
    top: 0;
    z-index: 500;
    background: rgba(3,7,12,0.94);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    backdrop-filter: blur(18px);
}

.logo {
    font-size: 17px;
    font-weight: 900;
    letter-spacing: 2px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-button {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 15px;
    border-radius: 10px;
    text-decoration: none;
    font-size: 11px;
    font-weight: 800;
    transition: 0.2s ease;
}

.header-button.secondary {
    color: #aab5c2;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
}

.header-button.secondary:hover {
    color: #5ff7d1;
    border-color: rgba(95,247,209,0.28);
}

.page {
    width: 100%;
    margin: 80px 0 70px;
    padding: 0 32px;
}

.profile-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(220px, .65fr);
    grid-template-areas: "heading stats" "avatar stats" "identity actions";
    gap: 24px 32px;
    min-height: 520px;
    padding: 30px;
    border-radius: 24px;
    border: 1px solid rgba(95,247,209,.13);
    background: radial-gradient(circle at 95% 0%,rgba(69,241,189,.14),transparent 45%), radial-gradient(circle at 0% 100%,rgba(124,58,237,.14),transparent 45%),rgba(10,15,22,.92);
}
.hero-heading { grid-area: heading; font-size: 18px; letter-spacing: 2px; align-self: start; }
.profile-hero > .hero-avatar { grid-area: avatar; justify-self: start; width: 200px; height: 200px; box-shadow: 0 0 0 10px rgba(95,247,209,.035); }
.profile-hero .profile-username { font-size: clamp(48px, 4vw, 68px); }
.profile-hero > .profile-main { grid-area: identity; align-self: end; padding-bottom: 8px; }
.profile-hero > .hero-actions { grid-area: actions; align-self: end; }
.profile-hero .hero-action { justify-content: space-between; gap: 12px; }
.profile-stats { grid-area: stats; display: grid; gap: 12px; align-self: start; }
.profile-stat { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; border-bottom: 1px solid rgba(255,255,255,.07); padding: 0 0 12px; }
.profile-stat > span { color: #8b99ab; font-size: 12px; }
.profile-stat strong { font-size: 18px; color: #dcece9; }
.profile-stat small { width: 100%; color: #748290; font-size: 10px; }
.collection-title { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.collection-count { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; min-height: 30px; padding: 4px 10px; border-radius: 9px; color: #65ead4; background: rgba(32,201,187,.08); border: 1px solid rgba(32,201,187,.22); font-size: 14px; font-variant-numeric: tabular-nums; }
#animeCollection { scroll-margin-top: 95px; }

.hero-avatar {
    width: 110px;
    height: 110px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 50%;
    color: #61eed0;
    font-size: 36px;
    font-weight: 900;
    background: linear-gradient(135deg,rgba(124,58,237,.38),rgba(32,201,187,.32));
    border: 3px solid rgba(83,245,205,.30);
}

.hero-avatar img {
    width: 100%;
    height: 100%;
    display: none;
    object-fit: cover;
}

.profile-main {
    width: 100%;
    min-width: 0;
}

.profile-label {
    margin: 0 0 8px;
    color: #55eec7;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 2.5px;
    text-transform: uppercase;
}

.profile-username {
    margin: 0;
    font-size: 42px;
    line-height: 1.1;
    overflow-wrap: anywhere;
}

.profile-email {
    margin: 8px 0 0;
    color: #7c8896;
    font-size: 13px;
    overflow-wrap: anywhere;
}

.profile-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 18px;
}

.meta-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 0 11px;
    border-radius: 10px;
    color: #9aa5b2;
    font-size: 10px;
    font-weight: 700;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.07);
}

.hero-actions {
    display: flex;
    flex-direction: column;
    gap: 9px;
    width: 100%;
}

.hero-action {
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 14px;
    border-radius: 10px;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
    font-size: 11px;
    font-weight: 900;
    transition: 0.2s ease;
}

.hero-action.primary {
    color: #03110d;
    border: none;
    background: linear-gradient( 135deg, #45f1bd, #66ebdb );
}

.hero-action.secondary {
    color: #74ead7;
    background: rgba(32,201,187,0.06);
    border: 1px solid rgba(32,201,187,0.18);
}

.hero-action:hover {
    transform: translateY(-2px);
}

.card {
    padding: 24px;
    border-radius: 19px;
    background: rgba(10,15,22,0.88);
    border: 1px solid rgba(255,255,255,0.075);
    box-shadow: 0 18px 55px rgba(0,0,0,0.20);
}

.card-label {
    margin: 0 0 7px;
    color: #626f7e;
    font-size: 9px;
    font-weight: 900;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

.card h2 {
    margin: 0 0 7px;
    font-size: 20px;
}

.card-description {
    margin: 0;
    color: #758190;
    font-size: 12px;
    line-height: 1.6;
}

.recent-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.view-all {
    flex: 0 0 auto;
    color: #65ead4;
    text-decoration: none;
    font-size: 10px;
    font-weight: 800;
}

.view-all:hover {
    text-decoration: underline;
}

.recent-grid {
    display: grid;
    grid-template-columns: repeat( 3, minmax(0, 1fr) );
    gap: 12px;
    margin-top: 22px;
}

.recent-card {
    position: relative;
    height: 210px;
    overflow: hidden;
    border-radius: 14px;
    background: #080d13;
    border: 1px solid rgba(255,255,255,.07);
}

.recent-card img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.recent-card::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient( to top, rgba(2,5,8,0.92), transparent 68% );
}

.recent-info {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 11px;
    z-index: 2;
}

.recent-title {
    margin: 0;
    color: white;
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recent-category {
    margin: 4px 0 0;
    color: #67e9d2;
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
}

.empty-recent {
    grid-column: 1 / -1;
    padding: 45px 20px;
    text-align: center;
    color: #6f7b89;
    font-size: 12px;
    border-radius: 14px;
    background: rgba(255,255,255,0.025);
    border: 1px dashed rgba(255,255,255,0.08);
}

#pageMessage {
    min-height: 20px;
    margin: 20px 0 0;
    color: #8e99a7;
    text-align: center;
    font-size: 12px;
}

.edit-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0,0,0,0.82);
    backdrop-filter: blur(12px);
}

.edit-modal.show {
    display: flex;
}

.edit-box {
    position: relative;
    width: min(470px,100%);
    max-height: calc(100dvh - 40px);
    overflow-y: auto;
    padding: 32px;
    border-radius: 21px;
    background: #0b1119;
    border: 1px solid rgba(255,255,255,.09);
}

.close-edit {
    position: absolute;
    top: 13px;
    right: 14px;
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: #8d98a6;
    background: rgba(255,255,255,0.05);
    font-size: 24px;
}

.edit-box h2 {
    margin: 0 0 8px;
    font-size: 24px;
}

.edit-description {
    margin: 0 0 24px;
    color: #737f8e;
    font-size: 12px;
    line-height: 1.6;
}

.edit-avatar-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 24px;
}

.edit-avatar {
    width: 105px;
    height: 105px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 50%;
    color: #61eed0;
    font-size: 28px;
    font-weight: 900;
    background: linear-gradient( 135deg, rgba(124,58,237,0.38), rgba(32,201,187,0.32) );
    border: 2px solid rgba(83,245,205,0.26);
}

.edit-avatar img {
    width: 100%;
    height: 100%;
    display: none;
    object-fit: cover;
}

#avatarFile {
    display: none;
}

.choose-image {
    margin-top: 12px;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 14px;
    cursor: pointer;
    border-radius: 9px;
    color: #74ead7;
    font-size: 10px;
    font-weight: 900;
    background: rgba(32,201,187,0.06);
    border: 1px solid rgba(32,201,187,0.18);
}

.image-note {
    margin-top: 8px;
    color: #5f6b79;
    font-size: 9px;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #aeb7c3;
    font-size: 12px;
    font-weight: 800;
}

.form-group input {
    width: 100%;
    height: 48px;
    padding: 0 14px;
    outline: none;
    border-radius: 10px;
    color: white;
    font-family: inherit;
    font-size: 13px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.10);
}

.form-group input:focus {
    border-color: rgba(69,241,189,0.58);
}

.form-group input:disabled {
    color: #687482;
    cursor: not-allowed;
}

.save-button {
    width: 100%;
    min-height: 47px;
    margin-top: 4px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    color: #03110d;
    font-family: inherit;
    font-size: 12px;
    font-weight: 900;
    background: linear-gradient( 135deg, #45f1bd, #66ebdb );
}

.save-button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

#editMessage {
    min-height: 20px;
    margin: 15px 0 0;
    text-align: center;
    color: #8e99a7;
    font-size: 11px;
    line-height: 1.5;
}

.profile-layout {
    display: grid;
    /* Wider cards, matching the marked screenshot. */
    grid-template-columns: minmax(0, 1.06fr) minmax(0, 1fr);
    justify-content: space-between;
    align-items: start;
    gap: 40px clamp(40px, 5vw, 140px);
}

.profile-left-stack, .profile-right-stack {
    display: flex;
    flex-direction: column;
    gap: 40px;
    min-width: 0;
}

.profile-wallpaper-card {
    min-height: 520px;
    padding: 40px;
}

.anime-watching-card {
    min-height: 520px;
    padding: 25px;
}

.empty-anime {
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #7c8896;
    border-radius: 14px;
    background: rgba(255,255,255,.03);
    border: 1px solid rgba(255,255,255,.06);
}

:focus-visible {
    outline: 2px solid #5ff7d1;
    outline-offset: 4px;
}

button:disabled {
    cursor: wait;
    opacity: .55;
}
@media (max-width: 950px) {
    .page { margin-top: 32px; padding: 0 20px; }
    .profile-layout { grid-template-columns: minmax(0, 1fr); max-width: 520px; margin: auto; gap: 24px; }
    .profile-left-stack { gap: 24px; }
    .profile-hero, .profile-wallpaper-card, .anime-watching-card { min-height: auto; }
    .profile-wallpaper-card { padding: 25px; }
    .top-header { padding: 12px 16px; gap: 16px; flex-wrap: wrap; }
}
@media (max-width: 380px) {
    .page { padding: 0 12px; }
    .profile-hero, .profile-wallpaper-card, .anime-watching-card { padding: 20px; }
    .recent-grid { gap: 8px; }
    .recent-card { height: 165px; }
    .recent-info { left: 6px; right: 6px; }
    .edit-box { padding: 28px 20px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}

@media (min-width: 951px) and (max-width: 1250px), (max-width: 540px) {
    .profile-hero { grid-template-columns: minmax(0,1fr) minmax(0,1fr); grid-template-areas: "heading heading" "avatar stats" "identity identity" "actions actions"; gap: 24px 16px; padding: 24px; }
    .profile-hero > .hero-avatar { width: clamp(110px, 24vw, 150px); height: clamp(110px, 24vw, 150px); max-width: 100%; aspect-ratio: 1; }
    .hero-heading { font-size: 13px; }
    .profile-hero .profile-username { font-size: 46px; }
}

@media (max-width: 380px) {
    .profile-hero > .hero-avatar { width: 110px; height: auto; }
    .profile-stat strong { font-size: 15px; }
}

/* Profile background upload, isolated from account and collection styles. */
.profile-hero { position: relative; isolation: isolate; overflow: hidden; }
.profile-hero.has-cover::before { content: ""; position: absolute; inset: 0; z-index: -1; background-image: linear-gradient(90deg,rgba(5,10,18,.65),rgba(5,10,18,.78)),var(--profile-cover-image); background-size: cover; background-position: center; pointer-events: none; }
.profile-hero > .cover-add { position: absolute; right: 28px; top: 36%; z-index: 2; width: 42px; height: 42px; padding: 0; border: 1px solid rgba(95,247,209,.5); border-radius: 12px; background: rgba(6,20,26,.85); color: #74ead7; font-size: 30px; cursor: pointer; }
.cover-dialog { width: min(520px,calc(100% - 32px)); max-height: 90dvh; overflow: auto; border: 1px solid #284d50; border-radius: 20px; padding: 26px; background: #0b1119; color: #eef6f5; }
.cover-dialog::backdrop { background: rgba(0,0,0,.78); backdrop-filter: blur(6px); }
.cover-dialog h2 { margin-top: 0; }
.cover-dialog p { color: #a6b8c4; font-size: 13px; line-height: 1.6; }
.cover-dialog label { display: block; margin-bottom: 10px; }
.cover-dialog input { max-width: 100%; }
#coverPreview { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 10px; margin-top: 18px; }
.cover-dialog-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.cover-dialog button { min-height: 42px; border: 1px solid #315954; border-radius: 9px; padding: 10px 14px; color: #9cf5dc; background: #102b2b; cursor: pointer; }
.cover-dialog #coverSave { background: #54e5c2; color: #071912; }
@media (max-width: 1250px) { .profile-hero > .cover-add { top: 20px; right: 20px; } .hero-heading { padding-right: 45px; } }

/* Separate page backdrop, below content and independent of the profile card. */
body.has-page-background {
    background-image: linear-gradient(rgba(4,8,16,.48),rgba(4,8,16,.65)),var(--profile-page-image);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
}
.page-background-toolbar { display: flex; justify-content: flex-end; padding: 16px 32px 0; height: 58px; }
.page-background-toolbar + .page { margin-top: 22px; }
.page-cover-add { width: 42px; height: 42px; padding: 0; border: 1px solid rgba(95,247,209,.5); border-radius: 12px; background: rgba(6,20,26,.85); color: #74ead7; font-size: 30px; cursor: pointer; }
#pageCoverPreview { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 10px; margin-top: 18px; }
.cover-dialog #pageCoverSave { background: #54e5c2; color: #071912; }
@media (max-width: 950px) {
    .page-background-toolbar { padding: 12px 20px 0; height: 54px; }
    .page-background-toolbar + .page { margin-top: 22px; }
}
