/* 🎨 몽실이의 마음연구소 메인 스타일 시트 */

:root {
    --bg: #ffffff;
    /* 깨끗한 화이트 배경 */
    --card: #ffffff;
    --line: rgba(0, 0, 0, 0.06);
    --line-soft: rgba(0, 0, 0, 0.04);
    --text-main: #1a1a1a;
    --text-sub: #767676;
    --brand: #ff4d4d;
    /* 웹툰 느낌의 강렬한 레드/오렌지 포인트 */
    --brand-soft: #fff5f5;
    --shadow-premium: 0 10px 30px rgba(0, 0, 0, 0.04);
    --radius-xl: 32px;
    --radius-lg: 20px;
    --radius-md: 12px;

    /* 웹툰 레이아웃 전용 변수 */
    --tab-height: 50px;
    --bottom-nav-height: 64px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    font-family: "Pretendard Variable", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text-main);
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

button {
    font-family: inherit;
}

header.main-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-bottom: 1px solid var(--line-soft);
}

.header-inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.logo-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.logo-wrap img {
    height: 48px !important;
    width: auto !important;
    max-width: 200px;
    border-radius: 0 !important;
    border: none !important;
    object-fit: contain;
    background: #ffffff;
    flex-shrink: 0;
}

.hero-mascot img {
    height: 80px !important;
    width: auto !important;
    object-fit: contain;
}

/* ===== 카테고리 스티키 탭 (웹툰 플랫폼 스타일) ===== */
.category-tabs {
    position: sticky;
    top: 56px;
    z-index: 999;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line-soft);
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.category-tabs::-webkit-scrollbar {
    display: none;
}

.tabs-inner {
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    padding: 0 16px;
    gap: 20px;
}

.tab-item {
    padding: 14px 4px;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-sub);
    white-space: nowrap;
    cursor: pointer;
    position: relative;
    transition: color 0.2s;
}

.tab-item.active {
    color: var(--brand);
}

.tab-item.active::after {
    content: "";
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--brand);
    border-radius: 999px;
}

/* 하단 내비게이션 바 */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: #ffffff !important;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    display: flex !important;
    align-items: center;
    justify-content: center;
    z-index: 99999 !important;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.05) !important;
}

.bottom-nav-inner {
    width: 100%;
    max-width: 600px;
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-sub);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
}

.nav-item.active {
    color: var(--brand);
}

.nav-item .icon {
    font-size: 1.4rem;
}

main {
    flex: 1;
}

.page {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 20px 100px;
}

@media (max-width: 480px) {
    .page {
        padding: 0 12px 100px;
    }
}

.hero {
    padding: 40px 0 20px;
    text-align: center;
    position: relative;
    animation: heroFadeIn 1s ease-out;
}

.hero-mascot {
    width: 80px;
    height: 80px;
    margin: 0 auto 16px;
    background: #ffffff;
    border-radius: 50%;
    padding: 10px;
    box-shadow: 0 8px 20px rgba(94, 73, 61, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero-mascot img {
    width: 60px;
    height: 60px;
    object-fit: contain;
}

.hero h1 {
    font-size: 1.8rem !important;
    font-weight: 800;
    color: var(--text-main);
    margin: 0;
}

.hero p {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-sub);
    line-height: 1.5;
}

.hero-tags {
    display: flex !important;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.hero-tags span {
    font-size: 0.75rem;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--text-sub);
}

.home-search {
    margin: 20px 0 40px;
    padding: 24px;
    border-radius: var(--radius-lg);
    background: #ffffff;
    box-shadow: var(--shadow-premium);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.home-search-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-main);
    font-weight: 700;
}

.home-search-input-wrap input {
    width: 100%;
    padding: 15px 24px;
    border-radius: 999px;
    border: 1px solid var(--line);
    font-size: 1rem;
    background: #f9f7f4;
    outline: none;
    transition: all 0.2s;
}

.home-search-input-wrap input:focus {
    border-color: var(--brand);
    background: #ffffff;
    box-shadow: 0 0 0 4px var(--brand-soft);
}

.home-search-input-wrap input::placeholder {
    color: #ab9a8f;
}

/* ===== 카테고리 섹션 및 카드 ===== */
.category-section {
    margin-top: 40px;
}

.category-header {
    margin: 0 0 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cat-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.category-header h2 {
    font-size: 1.25rem;
    font-weight: 900;
    letter-spacing: -0.04em;
    margin: 0;
}

.category-header p {
    font-size: 0.85rem;
    color: var(--text-sub);
    margin: 0;
    line-height: 1.4;
    word-break: keep-all;
}

.category-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    padding-bottom: 24px;
}

@media (max-width: 768px) {
    .category-row {
        grid-template-columns: repeat(4, 1fr);
        gap: 14px;
    }
}

@media (max-width: 480px) {
    .category-row {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        padding-bottom: 24px;
    }
}

.card {
    background: var(--card);
    display: flex;
    flex-direction: column;
    gap: 8px;
    cursor: pointer;
    padding: 0;
    border: 1px solid var(--line-soft) !important;
    box-shadow: none;
    text-align: left;
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
}

.card:hover {
    transform: translateY(-6px) !important;
    border-color: var(--brand) !important;
    box-shadow: 0 20px 40px rgba(94, 73, 61, 0.1) !important;
}

.card .rank-badge {
    position: absolute;
    top: 0;
    left: 0;
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 0.8rem;
    z-index: 2;
    border-bottom-right-radius: 6px;
}

.card .rank-badge.gold {
    background: #ffbc00;
}

.card .rank-badge.silver {
    background: #bcc6cc;
}

.card .rank-badge.bronze {
    background: #cd7f32;
}

.card .chip {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 800;
    background: var(--brand);
    color: #fff;
    z-index: 2;
    box-shadow: 0 2px 8px rgba(255, 77, 77, 0.3);
}

.card .anim {
    width: 100%;
    padding-top: 100%;
    position: relative;
    background: var(--brand-soft) !important;
    overflow: hidden;
}

.card h3 {
    margin: 8px 8px 12px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-main);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.25;
}

/* ✨ 프리미엄 코드 아트 */
.premium-glass-art {
    background: linear-gradient(135deg, #fff7ed 0%, #fffbf5 100%) !important;
    position: relative;
    border: 1px solid rgba(255, 148, 104, 0.1) !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.premium-glass-art::before {
    content: "";
    position: absolute;
    width: 140px;
    height: 140px;
    background: radial-gradient(circle, rgba(255, 148, 104, 0.2) 0%, transparent 70%);
    filter: blur(25px);
    animation: geminiMove 6s infinite alternate ease-in-out;
    z-index: 0;
}

.premium-glass-art .emoji {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3.6rem;
    z-index: 2;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.12));
    animation: geminiFloat 3s infinite ease-in-out;
}

@keyframes geminiMove {
    from {
        transform: translate(-30%, -30%);
    }

    to {
        transform: translate(30%, 30%);
    }
}

@keyframes geminiFloat {

    0%,
    100% {
        transform: translate(-50%, -50%) translateY(0) rotate(0);
    }

    50% {
        transform: translate(-50%, -50%) translateY(-12px) rotate(5deg);
    }
}

/* ===== 탭 시스템 ===== */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.age-tabs,
.theme-filter-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    overflow-x: auto;
    scrollbar-width: none;
}

.age-tab,
.theme-tab {
    padding: 10px 20px;
    border: 1.5px solid var(--line);
    border-radius: 999px;
    background: #fff;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-sub);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.age-tab.active,
.theme-tab.active {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

/* ===== 햄버거 메뉴 및 드롭다운 ===== */
.hamburger-btn {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--text-main);
    border-radius: 8px;
}

/* ===== 더보기 메뉴 (Side Panel) ===== */
.menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100001;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    justify-content: flex-end;
    visibility: hidden;
    opacity: 0;
    transition: all 0.3s ease;
    backdrop-filter: blur(4px);
}

.menu-backdrop.open {
    visibility: visible;
    opacity: 1;
}

.menu-panel {
    width: 280px;
    max-width: 85%;
    height: 100%;
    background: #fff;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.menu-backdrop.open .menu-panel {
    transform: translateX(0);
}

.menu-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 20px;
    border-bottom: 1px solid var(--line-soft);
}

.menu-title-left {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-main);
}

.menu-close-btn {
    background: none;
    border: none;
    font-size: 1.4rem;
    color: var(--text-sub);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.menu-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

.menu-item {
    display: block;
    padding: 16px 24px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s;
}

.menu-item:hover {
    background: var(--brand-soft);
    color: var(--brand);
    padding-left: 30px;
}

/* 🗑️ 카드 삭제 버튼 */
.card-delete-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    opacity: 0.7;
    /* 기본 채도 상승 */
    transition: all 0.2s;
    font-size: 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 100, 100, 0.2);
    /* 붉은색 테두리 추가 */
}

.card:hover .card-delete-btn {
    opacity: 1;
    /* 호버 시 완전 노출 */
}

.card-delete-btn:hover {
    background: #ff4d4d !important;
    opacity: 1 !important;
    transform: scale(1.15);
    color: #fff;
    box-shadow: 0 4px 15px rgba(255, 77, 77, 0.4);
}

/* ===== 카테고리 탭 내부 검색바 ===== */
.category-tabs-inner {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: 54px;
}

.tabs-list {
    display: flex;
    gap: 20px;
}

.tab-search-wrap {
    display: flex;
    align-items: center;
    background: #f4f4f4;
    border-radius: 99px;
    padding: 6px 12px;
    width: 140px;
    transition: width 0.3s ease;
}

.tab-search-wrap:focus-within {
    width: 180px;
    background: #fff;
    box-shadow: 0 0 0 1px var(--brand-soft);
}

.tab-search-wrap input {
    border: none;
    background: transparent;
    font-size: 0.85rem;
    width: 100%;
    outline: none;
}

/* ===== 배너 시스템 ===== */
.today-banner {
    margin: 16px 0;
    border-radius: 12px;
    min-height: 160px;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    padding: 24px;
    color: #fff;
    cursor: pointer;
}

.banner-content {
    z-index: 2;
    flex: 1;
}

.banner-tag {
    background: var(--brand);
    font-size: 0.65rem;
    font-weight: 900;
    padding: 2px 6px;
    border-radius: 4px;
    margin-bottom: 6px;
    display: inline-block;
}

.banner-content h2 {
    font-size: 1.25rem;
    margin: 4px 0;
    line-height: 1.2;
}

.banner-img {
    opacity: 0.4;
    position: absolute;
    right: -10px;
    bottom: -10px;
    transform: rotate(-15deg);
}

@keyframes pop {
    0% {
        transform: scale(0.98);
        opacity: 0.9;
    }

    50% {
        transform: scale(1.02);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.anim-pop {
    animation: pop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* 스크롤 애니메이션 */
.card,
.category-header,
.today-pick-inner,
.home-search {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.revealed {
    opacity: 1 !important;
    transform: translateY(0) !important;
}

/* ===== 로딩 스피너 (AI 도움용) ===== */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(98, 0, 234, 0.1);
    border-top: 3px solid #6200EA;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

#aiAssistLoading {
    position: fixed !important;
    /* 뷰포트 중앙 고정 */
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 999999;
    /* 최상단 */
}

/* 공통 리셋 및 스크롤바 */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 999px;
}