:root {
    /* 배경/텍스트를 직접 지정하지 않은 네이티브 폼 컨트롤(검색창 등)·스크롤바가
       테마를 따라가게 한다. 아래 다크 오버라이드 블록들에서 함께 바꾼다. */
    color-scheme: light;
    --primary-color: #FF5722;
    /* Deep Orange */
    --primary-dark: #E64A19;
    --primary-light: #FFCCBC;
    --text-color: #333;
    --text-secondary-color: #666;
    --text-muted-color: #999;
    --bg-color: #f5f5f5;
    --surface-color: #ffffff;
    --surface-alt-color: #f5f5f5;
    --border-color: #e0e0e0;
    /* 강조용 파스텔 틴트. 배경은 여기서 테마에 맞게 바뀌지만, 그 위에 얹히는
       텍스트는 대개 var(--text-color) 계열을 그대로 상속받는다 — 즉 이 토큰들이
       라이트 값 그대로 하드코딩되어 있으면 다크모드에서 "밝은 카드 위에 밝은
       글자"가 되어 내용이 안 보인다. 반드시 아래 다크 오버라이드와 짝을 맞출 것. */
    --tint-orange-bg: #FFF3E0;
    --tint-orange-bg-strong: #FFE0B2;
    --tint-amber-bg: #FFF8E1;
    --tint-yellow-bg: #FFFDE7;
    --tint-yellow-bg-strong: #FFF9C4;
    --tint-brand-bg: #FFF8F5;
    --tint-mint-bg: #F0FAF0;
    --tint-blue-bg: #F5F9FF;
    --tint-blue-bg-strong: #E3F2FD;
    --sidebar-width: 280px;
    --header-height: 60px;
    --transition-speed: 0.3s;
    --sidebar-collapsed-width: 80px;
}

/* 다크모드: 시스템 설정을 기본으로 따르되(prefers-color-scheme),
   사용자가 theme.js로 명시 선택하면 [data-theme]가 그 값을 덮는다.
   :not([data-theme="light"])는 시스템이 dark인데 사용자가 명시로 light를
   고른 경우 media query 쪽이 이기지 않도록 막는 가드다. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --text-color: #e8e8e8;
        --text-secondary-color: #a8a8a8;
        --text-muted-color: #888;
        --bg-color: #121212;
        --surface-color: #1e1e1e;
        --surface-alt-color: #262626;
        --border-color: #3a3a3a;
        --tint-orange-bg: #4a3018;
        --tint-orange-bg-strong: #5c3d1f;
        --tint-amber-bg: #473f1f;
        --tint-yellow-bg: #4a4419;
        --tint-yellow-bg-strong: #5c561f;
        --tint-brand-bg: #4a3229;
        --tint-mint-bg: #253a2b;
        --tint-blue-bg: #24344a;
        --tint-blue-bg-strong: #2c4a6b;
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --text-color: #e8e8e8;
    --text-secondary-color: #a8a8a8;
    --text-muted-color: #888;
    --bg-color: #121212;
    --surface-color: #1e1e1e;
    --surface-alt-color: #262626;
    --border-color: #3a3a3a;
    --tint-orange-bg: #4a3018;
    --tint-orange-bg-strong: #5c3d1f;
    --tint-amber-bg: #473f1f;
    --tint-yellow-bg: #4a4419;
    --tint-yellow-bg-strong: #5c561f;
    --tint-brand-bg: #4a3229;
    --tint-mint-bg: #253a2b;
    --tint-blue-bg: #24344a;
    --tint-blue-bg-strong: #2c4a6b;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Noto Serif KR', serif;
    background-color: var(--bg-color);
    color: var(--text-color);
}

/* 제목·HERO·사이드바·버튼 류는 본문 serif에서 제외하고 sans 유지 */
h1, h2, h3, h4, h5, h6,
[class*="hero"],
[class*="title"],
[class*="heading"],
.sidebar,
button,
.btn,
[class*="btn-"],
[class*="btn--"] {
    font-family: 'Noto Sans KR', sans-serif;
}

.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--surface-color);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
    transform: translateX(-100%);
    /* Hidden by default on mobile */
    transition: width var(--transition-speed) ease, transform var(--transition-speed) ease;
    overflow-x: hidden;
    white-space: nowrap;
}

.sidebar.open {
    transform: translateX(0);
}

.sidebar-header {
    height: var(--header-height);
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    /* 접힘 시 padding으로 토글 버튼을 옮기므로 보간 대상에 넣는다 */
    transition: padding var(--transition-speed) ease;
}

.sidebar-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    /* 사이드바가 좁아질 때 0까지 줄어들며 잘리도록 (display:none이면 버튼이 튄다) */
    flex: 1;
    min-width: 0;
    overflow: hidden;
    transition: opacity 0.18s ease;
}

.toggle-btn {
    background: transparent !important;
    border: none;
    color: white;
    cursor: pointer;
    display: grid;
    place-items: center;
    padding: 0;
    outline: none;
    /* 헤더가 좁아지는 동안 버튼이 찌그러지지 않게 (h2만 줄어들어야 한다) */
    flex-shrink: 0;
    /* material-icons이 텍스트 글리프라 클릭+미세이동에 브라우저가 텍스트 드래그로 오인한다 */
    -webkit-user-select: none;
    user-select: none;
    -webkit-user-drag: none;
}

.toggle-btn:focus,
.toggle-btn:active {
    background: transparent !important;
    outline: none;
}

/* 토글 아이콘: 펼친 상태=first_page(|←, 접을 수 있음), 접힌 상태=menu(햄버거).
   두 아이콘을 같은 칸에 겹쳐두고 회전+페이드로 전환한다. */
.sb-toggle-icon {
    grid-area: 1 / 1;
    transition: opacity 0.18s ease, transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.sb-toggle-icon--collapse {
    opacity: 1;
    transform: none;
}

.sb-toggle-icon--expand {
    opacity: 0;
    transform: rotate(-90deg) scale(0.7);
}

/* 접힌 상태 — 인라인 스크립트(html.sidebar-is-collapsed)와 aria-expanded 양쪽에서 적용해
   첫 페인트부터 아이콘이 어긋나지 않게 한다. */
.sidebar-is-collapsed .sb-toggle-icon--collapse,
.toggle-btn[aria-expanded="false"] .sb-toggle-icon--collapse {
    opacity: 0;
    transform: rotate(90deg) scale(0.7);
}

.sidebar-is-collapsed .sb-toggle-icon--expand,
.toggle-btn[aria-expanded="false"] .sb-toggle-icon--expand {
    opacity: 1;
    transform: none;
}

@media (prefers-reduced-motion: reduce) {
    .sb-toggle-icon {
        transition: opacity 0.1s ease;
        transform: none !important;
    }
}

.menu-list {
    list-style: none;
    padding: 20px 0;
}

.menu-list li a {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    text-decoration: none;
    color: var(--text-color);
    font-size: 1rem;
    transition: background-color 0.2s, padding var(--transition-speed) ease;
    height: 50px;
}

.menu-list li a:hover {
    background-color: var(--primary-light);
    color: var(--primary-dark);
}

.menu-list li a.active {
    background-color: var(--primary-light);
    color: var(--primary-dark);
    border-right: 3px solid var(--primary-color);
    font-weight: 500;
}

.menu-list li a.active .material-icons {
    color: var(--primary-dark);
}

.menu-list li a.disabled {
    color: var(--text-muted-color);
    cursor: default;
    pointer-events: none;
}

.menu-list li a.disabled:hover {
    background-color: transparent;
    color: var(--text-muted-color);
}

.menu-list li a.disabled .material-icons {
    color: var(--border-color);
}

.badge-coming-soon {
    font-size: 0.65rem;
    background-color: var(--border-color);
    color: var(--text-muted-color);
    padding: 1px 6px;
    border-radius: 8px;
    margin-left: auto;
    font-weight: 500;
    white-space: nowrap;
    transition: opacity 0.18s ease;
}

.menu-group {
    margin: 4px 0;
    padding: 0 12px;
    transition: padding var(--transition-speed) ease, margin var(--transition-speed) ease;
}

.menu-group-toggle {
    display: flex;
    align-items: center;
    width: 100%;
    background: none;
    border: none;
    border-top: 1px solid var(--border-color);
    padding: 12px 8px;
    cursor: pointer;
    color: var(--text-secondary-color);
    gap: 12px;
    transition: padding var(--transition-speed) ease;
}

.menu-group-toggle:hover {
    color: var(--primary-color);
}

.menu-group-icon {
    font-size: 22px !important;
    flex-shrink: 0;
    /* 그룹은 <button> 안이라 .menu-list li a .material-icons 규칙이 닿지 않는다.
       색을 안 주면 라벨용 #666을 상속해 아이콘만 혼자 회색이 된다. */
    color: var(--primary-color);
    /* 접힘 시 일반 메뉴 아이콘(24px)과 세로 중심선을 맞춘다 */
    min-width: 24px;
    text-align: center;
}

.menu-group-label {
    font-size: 0.88rem;
    font-weight: 600;
    flex: 1;
    text-align: left;
    white-space: nowrap;
    transition: opacity 0.18s ease;
}

.menu-group-arrow {
    font-size: 18px !important;
    transition: transform 0.2s, opacity 0.18s ease;
}

.menu-group--collapsed .menu-group-arrow {
    transform: rotate(-90deg);
}

.menu-group-list {
    list-style: none;
    padding: 0;
    overflow: hidden;
    max-height: 500px;
    transition: max-height 0.25s ease;
}

.menu-group--collapsed .menu-group-list {
    max-height: 0;
}

.menu-group-list li a {
    padding-left: 46px !important;
    font-size: 0.88rem;
}

.menu-group-list li a .material-icons {
    display: none;
}

.menu-list li a .material-icons {
    margin-right: 15px;
    color: var(--primary-color);
    min-width: 24px;
}

.menu-list li a .menu-label {
    transition: opacity 0.2s;
}

/* Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 900;
    display: none;
}

.overlay.active {
    display: block;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 0;
    transition: margin-left var(--transition-speed) ease;
    width: 100%;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.top-bar {
    height: var(--header-height);
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    padding: 0 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: 100;
    transition: left var(--transition-speed) ease;
}

.menu-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    margin-right: 20px;
}

.top-bar h1 {
    font-size: 1.25rem;
    font-weight: 500;
    /* 아이콘 그룹(다크모드 토글·벨·계정) 전체를 오른쪽 끝으로 미는 유일한 지점.
       아이콘마다 margin-left: auto를 각자 넣으면 여백이 아이콘 개수만큼 쪼개져
       흩어져 붙는다 — 반드시 여기 하나로만 관리할 것. 각 아이콘의 좌우 순서는
       DOM 삽입 순서(스크립트 로딩 타이밍에 따라 달라짐)가 아니라 order로 고정한다. */
    margin-right: auto;
}

.content-area {
    padding: 20px;
    padding-top: calc(var(--header-height) + 20px);
    flex: 1;
    display: flex;
    flex-direction: column;
}

.welcome-card {
    background-color: var(--surface-color);
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
    border-left: 5px solid var(--primary-color);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.card {
    background-color: var(--surface-color);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s;
}

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

.card h3 {
    margin-bottom: 10px;
    color: var(--primary-color);
}

/* ===== Footer ===== */
.app-footer {
    text-align: center;
    padding: 24px 16px 16px;
    margin-top: auto;
    border-top: 1px solid var(--border-color);
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 8px;
}

.footer-links a {
    font-size: 0.8rem;
    color: var(--text-muted-color);
    text-decoration: none;
}

.footer-links a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.footer-copy {
    font-size: 0.72rem;
    color: var(--text-muted-color);
    margin: 0;
}


/* ===== 법적 페이지 ===== */
.legal-hero {
    text-align: center;
    padding: 20px 0 24px;
    margin-bottom: 8px;
}

.legal-content .legal-hero h2 {
    font-size: 2.5rem;
    font-weight: 800;
    margin: 0 0 6px 0;
    border: none;
    padding: 0;
    color: var(--text-color);
}

.legal-hero p {
    margin: 0;
    font-size: 0.88rem;
    color: var(--text-muted-color);
}

.legal-content {
    max-width: 720px;
    margin: 0 auto;
    padding: 24px;
    background: var(--surface-color);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    line-height: 1.8;
    color: var(--text-color);
    font-size: 0.9rem;
}

.legal-intro {
    background: var(--surface-alt-color);
    padding: 16px 20px;
    border-radius: 8px;
    font-size: 0.88rem;
    color: var(--text-secondary-color);
    margin-bottom: 28px;
}

.legal-content h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
    margin: 32px 0 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.legal-content ol,
.legal-content ul {
    padding-left: 24px;
    margin: 8px 0 16px;
}

.legal-content li {
    margin-bottom: 6px;
}

.legal-content a {
    color: var(--primary-color);
    text-decoration: none;
}

.legal-content a:hover {
    text-decoration: underline;
}

.legal-table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0 20px;
    font-size: 0.85rem;
}

.legal-table th,
.legal-table td {
    border: 1px solid var(--border-color);
    padding: 10px 14px;
    text-align: left;
}

.legal-table th {
    background: var(--surface-alt-color);
    font-weight: 600;
    color: var(--text-secondary-color);
}

.legal-appendix {
    margin-top: 40px;
    padding: 16px 20px;
    background: var(--surface-alt-color);
    border-radius: 8px;
    font-size: 0.88rem;
}

.legal-appendix p {
    margin: 6px 0 0;
}

/* Mobile Touch Target */
@media (max-width: 767px) {
    .menu-list a {
        min-height: 48px;
        padding: 12px 20px;
    }
}

/* Desktop Styles */
@media (min-width: 768px) {
    /* 데스크톱은 항상 보이므로 이동이 필요 없다. transform이 남아 있으면 그것이
       fixed 자식(접힘 툴팁·플라이아웃)의 기준이 되어 overflow에 잘리므로 none으로 둔다.
       .open은 모바일에서 붙은 채 창을 넓혔을 때를 대비해 함께 지운다. */
    .sidebar,
    .sidebar.open {
        transform: none;
    }

    .main-content {
        margin-left: var(--sidebar-width);
    }

    .main-content .top-bar {
        left: var(--sidebar-width);
    }

    .menu-btn {
        display: none;
        /* Hide toggle button on desktop */
    }

    .overlay {
        display: none !important;
        /* Never show overlay on desktop */
    }

    /* Collapsed Sidebar State (Desktop Only) */
    .sidebar.collapsed,
    .sidebar-is-collapsed .sidebar {
        width: var(--sidebar-collapsed-width);
    }

    /* 접힘 정렬은 justify-content(보간 불가)가 아니라 padding으로 만든다.
       접힌 폭 80px - 아이콘 24px = 좌우 28px → 아이콘이 정확히 중앙에 온다.
       정렬을 바꾸면 넓은 폭의 중앙으로 순간이동한 뒤 왼쪽으로 끌려오는 게 보인다. */
    .sidebar.collapsed .sidebar-header,
    .sidebar-is-collapsed .sidebar .sidebar-header {
        padding: 0 28px;
    }

    .sidebar.collapsed .sidebar-header h2,
    .sidebar-is-collapsed .sidebar .sidebar-header h2 {
        opacity: 0;
    }

    .sidebar.collapsed .menu-list li a,
    .sidebar-is-collapsed .sidebar .menu-list li a {
        padding: 15px 28px;
    }

    .sidebar.collapsed .menu-list li a.active,
    .sidebar-is-collapsed .sidebar .menu-list li a.active {
        border-right: none;
        background-color: var(--primary-light);
    }

    /* 펼친 상태: 텍스트 표시. 폭은 건드리지 않는다 —
       width: auto ↔ 0은 보간되지 않아 텍스트가 즉시 사라져 버린다. */
    .menu-list li a .menu-label {
        transition: opacity 0.18s ease;
        opacity: 1;
        white-space: nowrap;
    }

    /* 접힌 상태: 그룹 — 아이콘만 표시, 서브메뉴 숨김.
       펼침 실효 들여쓰기 12(.menu-group) + 8(.menu-group-toggle) = 20px → 28px */
    .sidebar.collapsed .menu-group-toggle,
    .sidebar-is-collapsed .sidebar .menu-group-toggle {
        padding: 12px 28px;
        border-top: none;
    }

    .sidebar.collapsed .menu-group-label,
    .sidebar.collapsed .menu-group-arrow,
    .sidebar-is-collapsed .sidebar .menu-group-label,
    .sidebar-is-collapsed .sidebar .menu-group-arrow {
        opacity: 0;
    }

    .sidebar.collapsed .menu-group,
    .sidebar-is-collapsed .sidebar .menu-group {
        padding: 0;
        margin: 0;
    }

    .sidebar.collapsed .menu-group-list,
    .sidebar-is-collapsed .sidebar .menu-group-list {
        max-height: 0 !important;
        overflow: hidden;
    }

    /* 접힌 상태: 텍스트·뱃지는 폭을 줄이지 않고 투명도로만 사라진다.
       넘치는 부분은 .sidebar의 overflow-x: hidden이 잘라내므로,
       사이드바가 좁아지는 것과 같은 속도로 자연스럽게 사라진다. */
    .sidebar.collapsed .menu-list li a .menu-label,
    .sidebar.collapsed .menu-list li a .badge-coming-soon,
    .sidebar-is-collapsed .sidebar .menu-list li a .menu-label,
    .sidebar-is-collapsed .sidebar .menu-list li a .badge-coming-soon {
        opacity: 0;
    }

    /* ===== 접힌 상태의 툴팁 · 플라이아웃 =====
       .sidebar의 overflow-x: hidden은 라벨 클리핑과 세로 스크롤(overflow-y가
       auto로 강제된다) 양쪽에 필요하므로 건드리지 않는다. 대신 툴팁·패널을
       position: fixed로 띄워 클리핑 자체를 벗어난다 — 그러려면 조상에
       transform이 없어야 해서 데스크톱에서는 transform: none으로 둔다.
       세로 위치는 sidebar.php가 hover 시 --sb-top/--sb-mid에 넣어준다. */

    /* 일반 메뉴: 라벨 말풍선 (li[data-tip], 그룹에는 붙지 않는다) */
    .sidebar.collapsed .menu-list > li[data-tip]::after,
    .sidebar-is-collapsed .sidebar .menu-list > li[data-tip]::after {
        content: attr(data-tip);
        position: fixed;
        left: calc(var(--sidebar-collapsed-width) + 10px);
        top: var(--sb-mid, -999px);
        transform: translate(-6px, -50%);
        background: #333;
        color: #fff;
        font-size: 0.82rem;
        line-height: 1;
        padding: 8px 11px;
        border-radius: 6px;
        white-space: nowrap;
        pointer-events: none;
        opacity: 0;
        transition: opacity 0.15s ease, transform 0.15s ease;
    }

    .sidebar.collapsed .menu-list > li[data-tip]:hover::after,
    .sidebar-is-collapsed .sidebar .menu-list > li[data-tip]:hover::after {
        opacity: 1;
        transform: translate(0, -50%);
    }

    /* 그룹: 하위 메뉴를 통째로 띄운다 — 접힌 상태에서 유일한 접근 경로다.
       사이드바에 딱 붙여야(간격 0) 아이콘→패널 이동 중에 hover가 끊기지 않는다. */
    .sidebar.collapsed .menu-group:hover .menu-group-list,
    .sidebar-is-collapsed .sidebar .menu-group:hover .menu-group-list {
        position: fixed;
        left: var(--sidebar-collapsed-width);
        top: var(--sb-top, -999px);
        min-width: 190px;
        max-height: none !important;
        overflow: visible;
        padding: 6px 0 8px;
        background: var(--surface-color);
        border-radius: 0 8px 8px 0;
        box-shadow: 2px 3px 12px rgba(0, 0, 0, 0.18);
        animation: sb-flyout 0.15s ease;
    }

    .sidebar.collapsed .menu-group:hover .menu-group-list::before,
    .sidebar-is-collapsed .sidebar .menu-group:hover .menu-group-list::before {
        content: attr(data-tip);
        display: block;
        padding: 8px 16px 10px;
        font-size: 0.78rem;
        font-weight: 600;
        color: var(--text-muted-color);
    }

    /* 패널 안에서는 접힘 규칙(라벨 숨김·중앙 padding)을 되돌린다 */
    .sidebar.collapsed .menu-group:hover .menu-group-list li a,
    .sidebar-is-collapsed .sidebar .menu-group:hover .menu-group-list li a {
        padding: 0 16px !important;
        height: 40px;
        overflow: visible;
    }

    .sidebar.collapsed .menu-group:hover .menu-group-list li a .menu-label,
    .sidebar-is-collapsed .sidebar .menu-group:hover .menu-group-list li a .menu-label {
        opacity: 1;
    }

    @keyframes sb-flyout {
        from {
            opacity: 0;
            transform: translateX(-6px);
        }
    }

    .sidebar.collapsed~.main-content,
    .sidebar-is-collapsed .sidebar~.main-content {
        margin-left: var(--sidebar-collapsed-width);
    }

    .sidebar.collapsed~.main-content .top-bar,
    .sidebar-is-collapsed .sidebar~.main-content .top-bar {
        left: var(--sidebar-collapsed-width);
    }
}

/* ===== 다크모드 토글 (top-bar) ===== */
.theme-toggle-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    order: 1;
}

.theme-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* ===== 계정 아이콘 (top-bar) ===== */
.topbar-account-btn {
    color: white;
    text-decoration: none;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    margin-left: 4px;
    order: 3;
}

.topbar-account-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* ===== 알림 Bell (top-bar) ===== */
.notif-bell-wrapper {
    margin-left: 4px;
    position: relative;
    order: 2;
}

.notif-bell-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    position: relative;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
}

.notif-bell-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.notif-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #f44336;
    color: white;
    font-size: 0.6rem;
    font-weight: 700;
    min-width: 17px;
    height: 17px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
}

.notif-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 340px;
    max-height: 420px;
    background: var(--surface-color);
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
    z-index: 200;
    overflow: hidden;
}

.notif-dropdown.show {
    display: block;
}

.notif-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-color);
}

.notif-mark-all {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 500;
}

.notif-mark-all:hover {
    text-decoration: underline;
}

.notif-dropdown-list {
    max-height: 300px;
    overflow-y: auto;
}

.notif-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    text-decoration: none;
    color: var(--text-color);
    transition: background 0.15s;
}

.notif-item:hover {
    background: var(--surface-alt-color);
}

.notif-item--unread {
    background: var(--tint-orange-bg);
}

.notif-item--unread:hover {
    background: var(--tint-orange-bg-strong);
}

.notif-item-icon {
    color: var(--primary-color);
    font-size: 20px;
    flex-shrink: 0;
    margin-top: 2px;
}

.notif-item-content {
    flex: 1;
    min-width: 0;
}

.notif-item-message {
    font-size: 0.85rem;
    line-height: 1.4;
    word-break: break-word;
}

.notif-item-time {
    font-size: 0.72rem;
    color: var(--text-muted-color);
    margin-top: 3px;
}

.notif-empty {
    padding: 32px 16px;
    text-align: center;
    color: var(--text-muted-color);
    font-size: 0.9rem;
}

.notif-dropdown-footer {
    display: block;
    text-align: center;
    padding: 11px;
    border-top: 1px solid var(--border-color);
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
}

.notif-dropdown-footer:hover {
    background: var(--surface-alt-color);
}

/* ===== 알림 전체 목록 페이지 ===== */
.notif-page-settings-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    color: var(--text-muted-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    text-decoration: none;
    transition: background-color 0.2s, color 0.2s;
}

.notif-page-settings-btn .material-icons {
    font-size: 18px;
}

.notif-page-settings-btn:hover {
    background-color: var(--surface-alt-color);
    color: var(--primary-dark);
}

.notif-page-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #FFF3E0;
    border-radius: 8px;
    margin-bottom: 16px;
}

.notif-page-count {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--primary-dark);
}

.notif-page-mark-all {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.82rem;
    cursor: pointer;
    font-weight: 500;
}

.notif-page-mark-all:hover {
    background: var(--primary-dark);
}

.notif-page-btns {
    display: flex;
    gap: 8px;
    align-items: center;
}

.notif-page-delete-all {
    background: none;
    color: var(--text-muted-color);
    border: 1px solid var(--border-color);
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.82rem;
    cursor: pointer;
    font-weight: 500;
}

.notif-page-delete-all:hover {
    color: #e53935;
    border-color: #e53935;
}

.notif-page-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted-color);
}

.notif-page-empty .material-icons {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
}

.notif-page-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: var(--border-color);
    border-radius: 12px;
    overflow: hidden;
}

.notif-page-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--surface-color);
    text-decoration: none;
    color: var(--text-color);
    transition: background 0.15s;
}

.notif-page-item:hover {
    background: var(--surface-alt-color);
}

.notif-page-item--unread {
    background: var(--tint-orange-bg-strong);
}

.notif-page-item--unread:hover {
    background: var(--tint-orange-bg);
}

.notif-page-item-icon {
    color: var(--primary-color);
    font-size: 24px;
    flex-shrink: 0;
}

.notif-page-item-content {
    flex: 1;
    min-width: 0;
}

.notif-page-item-message {
    font-size: 0.9rem;
    line-height: 1.4;
    word-break: break-word;
}

.notif-page-item-meta {
    display: flex;
    gap: 12px;
    font-size: 0.75rem;
    color: var(--text-muted-color);
    margin-top: 4px;
}

.notif-page-item-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary-color);
    flex-shrink: 0;
    align-self: center;
}

.notif-page-more {
    text-align: center;
    padding: 16px;
}

.notif-page-more-btn {
    display: inline-block;
    padding: 8px 24px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.85rem;
}

.notif-page-more-btn:hover {
    background: var(--surface-alt-color);
}

/* 모바일 드롭다운 너비 조정 */
@media (max-width: 767px) {
    .notif-dropdown {
        position: fixed;
        top: calc(var(--header-height) + 4px);
        right: 16px;
        left: 16px;
        width: auto;
    }
}

/* ===== iOS PWA 설치 안내 배너 ===== */
.pwa-install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface-color);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    z-index: 9999;
    padding: 14px 16px;
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
    animation: pwa-slide-up 0.3s ease-out;
}

@keyframes pwa-slide-up {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.pwa-install-banner--hide {
    animation: pwa-slide-down 0.3s ease-in forwards;
}

@keyframes pwa-slide-down {
    to { transform: translateY(100%); }
}

.pwa-install-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pwa-install-icon img {
    border-radius: 10px;
}

.pwa-install-text {
    flex: 1;
}

.pwa-install-text strong {
    font-size: 0.95rem;
    color: var(--text-color);
    display: block;
}

.pwa-install-text p {
    font-size: 0.8rem;
    color: var(--text-muted-color);
    margin: 2px 0 0;
}

.pwa-install-close {
    background: none;
    border: none;
    color: var(--text-muted-color);
    cursor: pointer;
    padding: 4px;
    flex-shrink: 0;
}

.pwa-install-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
    padding: 10px;
    background: var(--surface-alt-color);
    border-radius: 8px;
}

.pwa-install-step {
    font-size: 0.82rem;
    color: var(--text-color);
    font-weight: 500;
}

.pwa-install-arrow {
    font-size: 16px;
    color: var(--primary-color);
}

/* 공용 이미지 모달 */
.image-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.85);
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.image-modal.active {
    display: flex;
}

.image-modal img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 8px;
    object-fit: contain;
}

/* 프로필 링크 */
.profile-link {
    color: inherit;
    text-decoration: none;
}

.profile-link:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

/* 게시물 본문 하단 여백 */
.post-detail-body {
    margin-bottom: 16px;
}

/* 운영자 작성 체크박스 */
.as-admin-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 0.88rem;
    color: var(--text-secondary-color);
    padding: 8px 0;
    user-select: none;
}
.as-admin-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
    cursor: pointer;
}
.as-admin-checkbox .material-icons {
    font-size: 20px;
    color: var(--primary-color);
}

/* 운영자 레이블 */
.admin-author-label {
    display: inline-flex;
    align-items: center;
    font-weight: 600;
    color: var(--primary-color);
    font-size: inherit;
}