.login-guard {
    padding: 40px 24px;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.95rem;
}

.login-guard a {
    color: var(--color-primary);
    font-weight: 700;
    text-decoration: underline;
}

:root {
    --color-bg: #eff8ff;
    --color-surface: #ffffff;
    --color-border: #d6ebfa;
    --color-text: #16313f;
    --color-text-muted: #5d7a8c;
    --color-primary: #0ea5e9;
    --color-primary-dark: #0284c7;
    --color-live: #ff3b5c;
    --color-chzzk: #00e575;
    --color-youtube: #ff0033;
    --color-social-icon: #7a92a3;
    --radius: 14px;
    --shadow: 0 4px 16px rgba(43, 39, 53, 0.06);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
}

a {
    text-decoration: none;
    color: inherit;
}

img {
    max-width: 100%;
    display: block;
}

/* Header
   브랜드/메뉴/로그인 세 덩어리를 3열 그리드에 두고 각자 시작/가운데/끝에 붙여서,
   좌우 폭이 서로 달라도(로그인 전후로 오른쪽 폭이 바뀌는 등) 메뉴가 항상 화면
   가운데에 오도록 했습니다. flexbox의 space-between이면 옆 칸 폭 차이만큼
   가운데 요소가 밀리는데, grid는 가운데 열 자체를 기준으로 정렬해서 안 밀립니다. */
.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    column-gap: 16px;
    padding: 14px 24px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.1rem;
    justify-self: start;
}

.brand-logo {
    position: relative;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--color-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
}

.brand-logo-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.brand-logo-fallback {
    display: none;
}

/* miniProfileUrl 이미지를 불러오지 못하면 "토" 글자로 대체합니다. */
.brand-logo.icon-empty .brand-logo-img {
    display: none;
}

.brand-logo.icon-empty .brand-logo-fallback {
    display: inline;
}

.main-nav {
    display: flex;
    gap: 22px;
    justify-self: center;
}

.main-nav a {
    font-size: 0.92rem;
    color: var(--color-text-muted);
    padding: 6px 2px;
    border-bottom: 2px solid transparent;
}

.main-nav a:hover {
    color: var(--color-text);
    border-bottom-color: var(--color-primary);
}

.main-nav a.active {
    color: var(--color-text);
    font-weight: 700;
    text-decoration: underline;
    text-decoration-color: var(--color-primary);
    text-decoration-thickness: 2px;
    text-underline-offset: 4px;
}

.header-search-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 50%;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-muted);
    cursor: pointer;
}

.header-search-btn:hover {
    color: var(--color-text);
    border-color: var(--color-primary);
}

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

.search-modal-dialog {
    max-width: 560px;
}

.search-modal-dialog .modal-header {
    gap: 12px;
}

.search-modal-input {
    flex: 1;
    min-width: 0;
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    color: var(--color-text);
    font: inherit;
    font-size: 0.9rem;
}

.header-search-results {
    max-height: 60vh;
    overflow-y: auto;
    padding: 6px 0 0;
}

.header-search-results[hidden] {
    display: none;
}

.header-search-group-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--color-text-muted);
    padding: 8px 8px 2px;
}

.header-search-result-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 8px;
}

.header-search-result-row:hover {
    background: var(--color-bg);
}

.header-search-result-thumb {
    width: 44px;
    height: 26px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
    background: var(--color-bg);
}

.header-search-result-text {
    min-width: 0;
}

.header-search-result-title {
    font-size: 0.84rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-search-result-sub {
    font-size: 0.74rem;
    color: var(--color-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-search-empty {
    padding: 10px 8px;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.header-auth {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-self: end;
}

/* 노래책 페이지의 곡 등록 모달 등에서 쓰던 범용 모달 껍데기를 여기로 옮겨서
   (검색 모달도 여기서 재사용) 헤더가 있는 모든 페이지에서 쓸 수 있게 했습니다. */
.modal-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100;
}

/* [hidden]과 .modal-overlay의 display 선언은 명시도가 같아서, 이 규칙이 없으면
   author 스타일(.modal-overlay { display:flex })이 브라우저 기본 [hidden]{display:none}
   보다 우선해 hidden 속성이 있어도 모달이 계속 보이는 문제가 있었습니다. */
.modal-overlay[hidden] {
    display: none;
}

/* 모달이 화면을 덮어도 뒤에 있는 body가 원래 스크롤 가능한 상태 그대로라, 모달
   위(특히 여백/배경 부분)에서 휠/터치로 스크롤하면 뒤 페이지가 같이 밀리는
   문제가 있었습니다. 열려있는 .modal-overlay가 하나라도 있으면 body 자체를
   못 움직이게 잠급니다. 검색 모달은 헤더(site-header.js) 안쪽에 있고 노래책/
   오팬무 모달은 body 바로 아래라 위치가 서로 달라서, 자손 선택자(직계 자식
   아님)로 둘 다 잡습니다. */
body:has(.modal-overlay:not([hidden])) {
    overflow: hidden;
}

.modal-dialog {
    width: 100%;
    max-width: 480px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.05rem;
}

.modal-close-btn {
    font-size: 1.3rem;
    line-height: 1;
    border: none;
    background: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 4px;
}

.modal-close-btn:hover {
    color: var(--color-text);
}

.modal-body {
    padding: 20px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: 999px;
    font-size: 0.88rem;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
}

/* [hidden]과 위 display 선언은 명시도가 같아서, 이 규칙이 없으면 author 스타일이
   브라우저 기본 [hidden]{display:none}보다 우선해 hidden 속성을 줘도 .btn 버튼이
   계속 보이는 문제가 있었습니다(예: 편집 권한자가 아닌데도 "등록된 요청" 버튼이
   보이거나, 곡 등록 모달이 수정 모드가 아닌데도 "삭제" 버튼이 보임). */
.btn[hidden] {
    display: none;
}

.page-notice {
    margin: 0 0 20px;
    padding: 12px 16px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    color: var(--color-text-muted);
    font-size: 0.82rem;
    line-height: 1.5;
}

.btn-login {
    background: var(--color-primary);
    color: #fff;
}

.btn-login:hover {
    background: var(--color-primary-dark);
}

.btn-secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border-color: var(--color-border);
}

.btn-secondary:hover {
    background: var(--color-bg);
}

.user-menu {
    position: relative;
}

.user-chip {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 5px 12px 5px 5px;
    border-radius: 999px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    font-size: 0.86rem;
    font-weight: 600;
    cursor: default;
}

.user-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    /* 칩과 드롭다운 사이에 빈 틈이 있으면 그 사이를 지날 때 호버가 끊겨서 마진 대신 패딩으로 여백을 줍니다. */
    padding-top: 6px;
    min-width: 140px;
}

.user-dropdown-inner {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.user-menu:hover .user-dropdown {
    display: block;
}

.user-dropdown-item {
    display: block;
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: none;
    font: inherit;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--color-text);
    text-align: left;
    cursor: pointer;
}

.user-dropdown-item:hover {
    background: var(--color-bg);
}

.user-chip .avatar {
    position: relative;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--color-primary-dark);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
}

.user-chip .avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-chip .avatar-fallback {
    display: none;
}

/* 프로필 사진이 없거나 로드에 실패하면 이미지를 숨기고 닉네임 첫 글자를 대신 보여줍니다. */
.user-chip .avatar.icon-empty .avatar-img {
    display: none;
}

.user-chip .avatar.icon-empty .avatar-fallback {
    display: inline;
}

/* Main */
main {
    max-width: 1080px;
    margin: 0 auto;
    padding: 32px 24px 64px;
}

/* 프로필 히어로: 배너 이미지 위에 프로필 카드가 아바타로 살짝 겹치고, 그 아래
   커뮤니티 링크가 이어지는 SNS 프로필 스타일 레이아웃입니다. */
.profile-hero {
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 28px;
    box-shadow: var(--shadow);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
}

.profile-hero-banner {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 32 / 9;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
}

.profile-hero-banner-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.85;
}

.profile-hero-banner.hero-empty .profile-hero-banner-img {
    display: none;
}

.profile-hero-banner.hero-empty::after {
    content: "assets/main-banner-image.png 에 메인 이미지를 추가해주세요";
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
}

.profile-hero-body {
    position: relative;
    display: flex;
    gap: 16px;
    padding: 0 24px 16px;
    margin-top: -36px;
}

.profile-hero-avatar-wrap {
    flex-shrink: 0;
}

.profile-hero-avatar {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--color-bg);
    border: 4px solid var(--color-surface);
    box-shadow: var(--shadow);
}

.profile-hero-info {
    flex: 1;
    min-width: 0;
    padding-top: 44px;
}

.profile-hero-name-row {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 8px;
}

.profile-hero-name-link:hover .profile-hero-name {
    text-decoration: underline;
}

.profile-hero-name {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--color-text);
}

.profile-hero-english-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-text-muted);
    letter-spacing: 0.04em;
}

.profile-hero-tagline {
    margin: 4px 0 0;
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

.profile-hero-stats {
    margin: 8px 0 0;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.profile-hero-stat-row {
    line-height: 1.6;
}

.profile-hero-stats b {
    color: var(--color-text);
    font-weight: 700;
}

.profile-hero-characteristics {
    margin: 8px 0 0;
    font-size: 0.82rem;
    color: var(--color-text-muted);
    line-height: 1.5;
    white-space: pre-line;
}

.profile-hero-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 24px 24px;
}

.profile-hero-links:empty {
    display: none;
}

@media (max-width: 560px) {
    .profile-hero-body {
        flex-direction: column;
        margin-top: -28px;
    }

    .profile-hero-avatar {
        width: 76px;
        height: 76px;
    }

    .profile-hero-info {
        padding-top: 0;
    }
}

.live-banner {
    border-radius: var(--radius);
    padding: 22px 26px;
    /* 라이브 중일 때는 썸네일(68px)이 들어가서 배너가 커지는데, 오프라인일 때도
       같은 높이를 유지해서 상태가 바뀔 때 레이아웃이 출렁이지 않게 합니다. */
    min-height: 112px;
    background: linear-gradient(135deg, #0c4a6e, #082f49);
    color: #fff;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 28px;
}

.live-banner.is-offline {
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.live-thumb {
    width: 120px;
    height: 68px;
    object-fit: cover;
    border-radius: 10px;
    flex-shrink: 0;
}

.live-info {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
    min-width: 0;
}

.live-info > div {
    min-width: 0;
}

.live-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--color-live);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.live-badge .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fff;
    animation: pulse 1.4s infinite;
}

.badge-offline {
    display: inline-flex;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--color-bg);
    color: var(--color-text-muted);
    font-size: 0.78rem;
    font-weight: 700;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.live-title {
    font-size: 1.02rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.live-sub {
    font-size: 0.82rem;
    opacity: 0.75;
    margin-top: 2px;
}

.btn-chzzk {
    background: var(--color-chzzk);
    color: #10331f;
    white-space: nowrap;
}

.btn-chzzk:hover {
    filter: brightness(0.95);
}

.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.02rem;
    font-weight: 700;
    margin: 0 0 14px;
}

.section-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.video-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.15s ease;
}

.video-card:hover {
    transform: translateY(-3px);
}

.video-thumb {
    position: relative;
    aspect-ratio: 16 / 9;
    background: #d9d3ea;
}

.video-thumb.video-empty {
    background: var(--color-bg);
    border: 1px dashed var(--color-border);
}

.video-thumb.is-shorts {
    aspect-ratio: 9 / 16;
    max-height: 320px;
    margin: 0 auto;
}

.video-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-tag {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 3px 9px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
}

.video-body {
    padding: 14px 16px;
}

.video-body .label {
    font-size: 0.74rem;
    font-weight: 700;
    color: var(--color-youtube);
    margin-bottom: 4px;
}

.video-body .title {
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.video-body .meta {
    margin-top: 8px;
    font-size: 0.78rem;
    color: var(--color-text-muted);
}

.channel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 32px;
}

.channel-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: transform 0.15s ease;
}

.channel-card:hover {
    transform: translateY(-2px);
}

.channel-icon {
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    overflow: hidden;
    background: var(--color-youtube);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.channel-icon-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.channel-icon-fallback {
    display: none;
}

/* 채널 프로필 이미지를 불러오지 못하면 "Y" 글자로 대체합니다. */
.channel-icon.icon-empty .channel-icon-img {
    display: none;
}

.channel-icon.icon-empty .channel-icon-fallback {
    display: inline;
}

.channel-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}

.channel-title {
    font-size: 0.88rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.channel-sub {
    font-size: 0.76rem;
    color: var(--color-text-muted);
}

.community-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px 7px 7px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    transition: background 0.15s ease, transform 0.15s ease;
}

.community-pill:hover {
    background: var(--color-primary);
    color: #fff;
    transform: translateY(-1px);
}

.community-pill-icon {
    position: relative;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    overflow: hidden;
    color: #fff;
    background: var(--color-social-icon);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.7rem;
    flex-shrink: 0;
}

.community-pill-icon-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.community-pill-icon-fallback {
    display: none;
}

/* 아이콘 이미지가 없거나 로드에 실패하면 이미지를 숨기고 이름 첫 글자를 대신 보여줍니다. */
.community-pill-icon.icon-empty .community-pill-icon-img {
    display: none;
}

.community-pill-icon.icon-empty .community-pill-icon-fallback {
    display: inline;
}

.community-pill-label {
    font-size: 0.82rem;
    font-weight: 600;
}

@media (max-width: 640px) {
    /* 좁은 화면에선 3열을 가로로 다 못 펼치니, 브랜드/로그인 영역을 한 줄에 두고
       메뉴는 그 아래 줄 전체 너비로 내려서(가로 스크롤 가능) 2행 그리드로 바꿉니다. */
    .site-header {
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "brand right"
            "nav nav";
        row-gap: 10px;
    }

    .brand {
        grid-area: brand;
    }

    .header-auth {
        grid-area: right;
    }

    .main-nav {
        grid-area: nav;
        justify-self: stretch;
        width: 100%;
        overflow-x: auto;
        gap: 16px;
    }

    .live-banner {
        flex-direction: column;
        align-items: flex-start;
    }

    .live-thumb {
        width: 100%;
        height: auto;
        aspect-ratio: 16 / 9;
    }
}

.scroll-top-btn {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid var(--color-border);
    background: var(--color-primary);
    color: #fff;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    box-shadow: var(--shadow);
    z-index: 20;
    transition: background 0.15s ease, transform 0.15s ease;
}

.scroll-top-btn:hover {
    background: var(--color-primary-dark);
    transform: translateY(-2px);
}

.scroll-top-btn[hidden] {
    display: none;
}
