/* ============================================================
   PicDescribe - 초등학교 4학년 그림 묘사 학습 사이트
   CSS Stylesheet
   ============================================================ */

/* ----- CSS Variables ----- */
:root {
    --primary: #4F46E5;
    --primary-dark: #4338CA;
    --primary-light: #EEF2FF;
    --accent: #F97316;
    --accent-light: #FFF7ED;
    --bg: #FFFFFF;
    --bg-alt: #F8FAFC;
    --bg-white: #FFFFFF;
    --text: #1E293B;
    --text-light: #64748B;
    --text-muted: #94A3B8;
    --success: #059669;
    --warning: #EA580C;
    --danger: #DC2626;
    --gold: #F59E0B;
    --silver: #9CA3AF;
    --bronze: #D97706;
    --border: #E2E8F0;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -2px rgba(0,0,0,0.04);
    --sidebar-width: 260px;
    --topbar-height: 56px;
}

/* ----- Dark Theme ----- */
[data-theme="dark"] {
    --primary: #818CF8;
    --primary-dark: #6366F1;
    --primary-light: #1E1B4B;
    --accent: #FB923C;
    --accent-light: #431407;
    --bg: #0F172A;
    --bg-alt: #1E293B;
    --bg-white: #1E293B;
    --text: #E2E8F0;
    --text-light: #94A3B8;
    --text-muted: #64748B;
    --success: #34D399;
    --warning: #FB923C;
    --danger: #F87171;
    --border: #334155;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow: 0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4), 0 2px 4px -2px rgba(0,0,0,0.3);
}

[data-theme="dark"] .category-card:nth-child(1)  { background: #422006; border-color: #78350F; }
[data-theme="dark"] .category-card:nth-child(2)  { background: #172554; border-color: #1E3A8A; }
[data-theme="dark"] .category-card:nth-child(3)  { background: #500724; border-color: #831843; }
[data-theme="dark"] .category-card:nth-child(4)  { background: #052E16; border-color: #14532D; }
[data-theme="dark"] .category-card:nth-child(5)  { background: #450A0A; border-color: #7F1D1D; }
[data-theme="dark"] .category-card:nth-child(6)  { background: #1E1B4B; border-color: #312E81; }
[data-theme="dark"] .category-card:nth-child(7)  { background: #431407; border-color: #7C2D12; }
[data-theme="dark"] .category-card:nth-child(8)  { background: #052E16; border-color: #14532D; }
[data-theme="dark"] .category-card:nth-child(9)  { background: #2E1065; border-color: #4C1D95; }
[data-theme="dark"] .category-card:nth-child(10) { background: #083344; border-color: #155E75; }
[data-theme="dark"] .category-card:nth-child(11) { background: #4A0D2B; border-color: #831843; }
[data-theme="dark"] .category-card:nth-child(12) { background: #422006; border-color: #854D0E; }

[data-theme="dark"] .grade-A { background: #422006; color: #FDE68A; }
[data-theme="dark"] .grade-B { background: #1E293B; color: #94A3B8; }
[data-theme="dark"] .grade-C { background: #431407; color: #FED7AA; }
[data-theme="dark"] .grade-D { background: #172554; color: #93C5FD; }

[data-theme="dark"] .good-points { background: #052E16; border-left-color: #34D399; }
[data-theme="dark"] .good-points h4 { color: #34D399; }
[data-theme="dark"] .improvements { background: #431407; border-left-color: #FB923C; }
[data-theme="dark"] .improvements h4 { color: #FB923C; }
[data-theme="dark"] .tip-box { background: #1E1B4B; border-left-color: #818CF8; }
[data-theme="dark"] .tip-box h4 { color: #818CF8; }

[data-theme="dark"] .nav-logout:hover { color: #F87171; background: #450A0A; }
[data-theme="dark"] .loading-overlay { background: rgba(15, 23, 42, 0.9); }

[data-theme="dark"] .btn-primary:disabled { background: #334155; color: #64748B; }

[data-theme="dark"] .form-group input,
[data-theme="dark"] .write-section textarea {
    background: #0F172A;
    color: #E2E8F0;
    border-color: #334155;
}

/* ----- 1. 리셋 & 기본 ----- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 19px;
    line-height: 1.7;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

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

ul, ol {
    list-style: none;
}

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

.container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 32px 24px;
}

.content-container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 32px 24px;
}

/* ----- 2. 사이드바 레이아웃 ----- */

/* 모바일 상단바 */
.mobile-topbar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    z-index: 200;
    align-items: center;
    padding: 0 16px;
}

.hamburger-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text);
    cursor: pointer;
    border-radius: var(--radius);
}

.hamburger-btn:hover {
    background: var(--bg-alt);
}

.topbar-title {
    flex: 1;
    text-align: center;
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
}

.topbar-avatar {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    text-decoration: none;
}

/* 앱 레이아웃 */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* 사이드바 */
.sidebar {
    width: var(--sidebar-width);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    background: var(--bg-white);
    border-right: 1px solid var(--border);
    z-index: 300;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -0.3px;
}

.sidebar-logo:hover {
    color: var(--primary);
}

/* 사이드바 사용자 정보 */
.sidebar-user {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.sidebar-user-top {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.sidebar-avatar {
    font-size: 28px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-alt);
    border-radius: var(--radius);
    flex-shrink: 0;
}

.sidebar-user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sidebar-nickname {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-level {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.sidebar-xp-bar {
    background: var(--bg-alt);
    border-radius: 4px;
    height: 6px;
    overflow: hidden;
}

.sidebar-xp-fill {
    height: 100%;
    background: linear-gradient(90deg, #FBBF24, #F59E0B);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.sidebar-xp-text {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    text-align: right;
}

/* 사이드바 네비게이션 */
.sidebar-nav {
    flex: 1;
    padding: 12px 12px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 500;
    color: var(--text-light);
    text-decoration: none;
    transition: all 0.15s;
    margin-bottom: 2px;
    min-height: 44px;
}

.nav-item:hover {
    background: var(--bg-alt);
    color: var(--text);
}

.nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.nav-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.nav-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 14px;
}

/* 사이드바 푸터 */
.sidebar-footer {
    padding: 12px 12px;
    border-top: 1px solid var(--border);
}

.nav-logout {
    color: var(--text-muted);
}

.nav-logout:hover {
    color: var(--danger);
    background: #FEF2F2;
}

/* 다크모드 토글 스위치 */
.theme-switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    margin-bottom: 2px;
    color: var(--text-light);
    font-size: 14px;
}
.theme-switch-row .theme-label {
    display: flex;
    align-items: center;
    gap: 10px;
}
.theme-switch-row .theme-label .nav-icon {
    font-size: 18px;
    width: 22px;
    text-align: center;
}
.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}
.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--border);
    border-radius: 24px;
    transition: background 0.25s;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.25s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch input:checked + .toggle-slider {
    background: var(--primary);
}
.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

/* 사이드바 오버레이 (모바일) */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 250;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* 메인 콘텐츠 영역 */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

/* 기존 site-header (하위 호환) */
.site-header {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    display: none;
}

.site-header nav {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
}

.site-header .logo {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
    letter-spacing: -0.3px;
}

.site-header .logo:hover {
    color: var(--primary);
}

.site-header .nav-links {
    display: flex;
    align-items: center;
    gap: 2px;
}

.site-header .nav-links a {
    font-size: 17px;
    color: var(--text-light);
    margin-left: 0;
    padding: 6px 12px;
    border-radius: 6px;
    transition: color 0.15s;
    font-weight: 500;
}

.site-header .nav-links a:hover {
    color: var(--text);
    background: transparent;
}

.site-header .nav-links a.active {
    color: var(--primary);
    background: transparent;
    font-weight: 600;
}

/* ----- 3. 카테고리 카드 그리드 (.category-grid) ----- */
.category-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 24px;
}

.category-card {
    background: var(--bg-alt);
    border-radius: var(--radius-lg);
    padding: 28px 16px;
    text-align: center;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: border-color 0.2s, background 0.2s, transform 0.15s;
}

.category-card:nth-child(1)  { background: #FEF3C7; border-color: #FDE68A; }
.category-card:nth-child(2)  { background: #DBEAFE; border-color: #BFDBFE; }
.category-card:nth-child(3)  { background: #FCE7F3; border-color: #FBCFE8; }
.category-card:nth-child(4)  { background: #D1FAE5; border-color: #A7F3D0; }
.category-card:nth-child(5)  { background: #FEE2E2; border-color: #FECACA; }
.category-card:nth-child(6)  { background: #E0E7FF; border-color: #C7D2FE; }
.category-card:nth-child(7)  { background: #FFF7ED; border-color: #FED7AA; }
.category-card:nth-child(8)  { background: #F0FDF4; border-color: #BBF7D0; }
.category-card:nth-child(9)  { background: #F5F3FF; border-color: #DDD6FE; }
.category-card:nth-child(10) { background: #ECFEFF; border-color: #A5F3FC; }
.category-card:nth-child(11) { background: #FDF2F8; border-color: #F9A8D4; }
.category-card:nth-child(12) { background: #FEF9C3; border-color: #FDE047; }

.category-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.category-card:active {
    transform: translateY(0);
}

.category-card .icon,
.category-card .category-icon {
    font-size: 52px;
    display: block;
    margin-bottom: 10px;
    line-height: 1.2;
}

.category-card .name,
.category-card .category-name {
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.2px;
}

.category-card .count {
    font-size: 16px;
    color: var(--text-light);
    margin-top: 4px;
}

/* ----- 4. 오늘의 학습 현황 (.today-stats) ----- */
.today-stats {
    background: transparent;
    color: var(--text);
    border-radius: 0;
    padding: 0 0 32px 0;
    margin-bottom: 0;
    text-align: left;
    font-size: 19px;
    border-bottom: 1px solid var(--border);
}

.today-stats h2 {
    font-size: 32px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.5px;
    margin-bottom: 6px;
}

.today-stats .stats-text {
    color: var(--text-light);
    font-size: 20px;
}

.today-stats .stats-text strong {
    color: var(--primary);
    font-weight: 600;
}

.today-stats .stats-row {
    display: flex;
    justify-content: flex-start;
    gap: 32px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.today-stats .stat {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.today-stats .stat .number {
    font-size: 34px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.5px;
}

.today-stats .stat .label {
    font-size: 16px;
    color: var(--text-light);
}

/* ----- 5. 이미지 갤러리 그리드 (.image-grid) ----- */
.image-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-top: 24px;
}

.image-card {
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition: opacity 0.2s;
    position: relative;
    background: var(--bg-alt);
}

.image-card:hover {
    opacity: 0.85;
}

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

.image-card .credit,
.image-card .image-credit {
    position: absolute;
    bottom: 0;
    left: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.5));
    color: rgba(255,255,255,0.9);
    width: 100%;
    padding: 20px 12px 10px;
    font-size: 15px;
    line-height: 1.3;
}

.image-card .image-title {
    padding: 10px 12px;
    font-size: 17px;
    font-weight: 500;
    color: var(--text);
}

/* ----- 6. 묘사 작성 페이지 (.describe-layout) ----- */
.describe-layout {
    display: flex;
    gap: 30px;
    flex-direction: column;
}

.image-section {
    width: 100%;
}

.image-section img {
    width: 100%;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.image-section .image-info {
    margin-top: 12px;
    font-size: 17px;
    color: var(--text-light);
}

.write-section {
    flex: 1;
}

.write-section textarea {
    width: 100%;
    min-height: 200px;
    border: 2px solid var(--primary-light);
    border-radius: var(--radius);
    padding: 16px;
    font-size: 20px;
    font-family: 'Noto Sans KR', sans-serif;
    resize: vertical;
    line-height: 1.7;
    color: var(--text);
    background: var(--bg-white);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.write-section textarea::placeholder {
    color: #B2BEC3;
}

.write-section textarea:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(66, 99, 235, 0.15);
}

/* ----- 7. 가이드 힌트 (.guide-hints) ----- */
.guide-hints {
    margin-bottom: 20px;
}

.guide-hints h3 {
    font-size: 22px;
    margin-bottom: 12px;
    color: var(--primary);
}

.guide-hints .hint {
    background: var(--bg);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 8px;
    font-size: 19px;
    line-height: 1.5;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.guide-hints .hint::before {
    content: '\1F4A1';
    flex-shrink: 0;
}

/* ----- 8. 글자수 카운터 (.char-counter) ----- */
.char-counter {
    font-size: 20px;
    margin: 10px 0;
    text-align: right;
    font-weight: 500;
}

.char-counter .under-limit {
    color: var(--danger);
}

.char-counter .over-limit {
    color: var(--success);
}

.char-counter .current-count {
    font-weight: 700;
    font-size: 20px;
}

/* ----- 9. 버튼 ----- */
.btn {
    display: inline-block;
    padding: 12px 24px;
    border-radius: var(--radius);
    font-size: 20px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background 0.15s, opacity 0.15s;
    text-align: center;
    font-family: 'Noto Sans KR', sans-serif;
    line-height: 1.4;
    letter-spacing: -0.1px;
}

.btn:active {
    opacity: 0.85;
}

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

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

.btn-primary:disabled {
    background: #CBD5E1;
    cursor: not-allowed;
}

.btn-secondary {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

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

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

.btn-accent:hover {
    background: #D97706;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 20px;
}

.btn-block {
    width: 100%;
    text-align: center;
}

.btn-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 16px;
}

/* ----- 10. 평가 결과 (.result-page) ----- */
.result-page {
    max-width: 800px;
    margin: 0 auto;
}

.grade-display {
    text-align: center;
    padding: 40px 20px;
    border-radius: var(--radius-lg);
    margin-bottom: 8px;
    position: relative;
    overflow: hidden;
}

.grade-display .grade {
    font-size: 80px;
    font-weight: 900;
    line-height: 1;
}

.grade-display .message {
    font-size: 20px;
    margin-top: 8px;
    font-weight: 600;
    opacity: 0.9;
}

.grade-display .total-score {
    font-size: 20px;
    margin-top: 6px;
    opacity: 0.7;
}

.grade-A {
    background: #FEF9C3;
    color: #713F12;
}

.grade-B {
    background: #F1F5F9;
    color: #475569;
}

.grade-C {
    background: #FEF3C7;
    color: #92400E;
}

.grade-D {
    background: #EFF6FF;
    color: #1E40AF;
}

/* ----- 11. 점수 막대그래프 (.score-bars) ----- */
.score-bars {
    background: transparent;
    border-radius: 0;
    padding: 24px 0;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.score-bars h3 {
    font-size: 17px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 20px;
    color: var(--text-light);
}

.score-item {
    margin-bottom: 16px;
}

.score-item:last-child {
    margin-bottom: 0;
}

.score-label {
    font-size: 20px;
    font-weight: 500;
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.score-bar {
    height: 8px;
    background: var(--bg-alt);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.score-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 1s ease;
    min-width: 0;
}

.score-value {
    font-size: 17px;
    color: var(--text-light);
    font-weight: 700;
}

/* ----- 12. 비교 섹션 (.comparison) ----- */
.comparison {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    margin-bottom: 32px;
    background: var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.comparison-box {
    background: var(--bg-white);
    padding: 20px;
}

.comparison-box h3 {
    margin-bottom: 10px;
    font-size: 16px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-light);
}

.comparison-box p,
.comparison-box .text-content {
    font-size: 20px;
    line-height: 1.8;
    color: var(--text);
    white-space: pre-wrap;
}

/* ----- 13. 피드백 (.feedback) ----- */
.feedback {
    margin-bottom: 24px;
}

.feedback h3 {
    font-size: 17px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
    color: var(--text-light);
}

.good-points {
    background: #F0FDF4;
    border-left: 3px solid var(--success);
    padding: 16px 20px;
    border-radius: 0 var(--radius) var(--radius) 0;
    margin-bottom: 12px;
    font-size: 20px;
    line-height: 1.7;
}

.good-points h4 {
    color: var(--success);
    margin-bottom: 8px;
    font-size: 17px;
    font-weight: 600;
}

.improvements {
    background: #FFF7ED;
    border-left: 3px solid var(--warning);
    padding: 16px 20px;
    border-radius: 0 var(--radius) var(--radius) 0;
    margin-bottom: 12px;
    font-size: 20px;
    line-height: 1.7;
}

.improvements h4 {
    color: var(--warning);
    margin-bottom: 8px;
    font-size: 17px;
    font-weight: 600;
}

.tip-box {
    background: var(--primary-light);
    border-left: 3px solid var(--primary);
    padding: 16px 20px;
    border-radius: 0 var(--radius) var(--radius) 0;
    font-size: 20px;
    line-height: 1.7;
}

.tip-box h4 {
    color: var(--primary);
    margin-bottom: 8px;
    font-size: 17px;
    font-weight: 600;
}

.feedback ul {
    list-style: disc;
    padding-left: 18px;
}

.feedback li {
    margin-bottom: 4px;
}

/* ----- 14. 학습 이력 (.history-page) ----- */
.history-page {
    max-width: 900px;
    margin: 0 auto;
}

.stats-summary {
    display: flex;
    gap: 16px;
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.stat-card {
    background: var(--bg-alt);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    text-align: center;
    flex: 1;
    min-width: 100px;
}

.stat-card .number {
    font-size: 32px;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.1;
    letter-spacing: -0.5px;
}

.stat-card .label {
    font-size: 16px;
    color: var(--text-light);
    margin-top: 4px;
    font-weight: 500;
}

.history-list {
    list-style: none;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 14px;
    background: transparent;
    border-radius: 0;
    padding: 14px 0;
    margin-bottom: 0;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border);
}

.history-item:hover {
    background: var(--bg-alt);
    margin: 0 -12px;
    padding: 14px 12px;
    border-radius: var(--radius);
    border-bottom-color: transparent;
}

.history-item img {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: var(--radius);
    flex-shrink: 0;
}

.history-item .item-info {
    flex: 1;
    min-width: 0;
}

.history-item .item-title {
    font-size: 20px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item .item-date {
    font-size: 15px;
    color: var(--text-muted);
    margin-top: 2px;
}

.grade-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    font-weight: 800;
    font-size: 20px;
    color: #fff;
    flex-shrink: 0;
}

.badge-A {
    background: #FBBF24;
    color: #78350F;
}

.badge-B {
    background: #A3E635;
    color: #365314;
}

.badge-C {
    background: #FB923C;
    color: #7C2D12;
}

.badge-D {
    background: #60A5FA;
    color: #1E3A8A;
}

/* ----- 15. 로딩 (.loading) ----- */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--primary-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-text {
    margin-top: 16px;
    font-size: 20px;
    color: var(--text-light);
    font-weight: 500;
}

/* ----- 16. 빈 상태 (.empty-state) ----- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state .empty-icon {
    font-size: 56px;
    margin-bottom: 16px;
    display: block;
    line-height: 1.2;
}

.empty-state .empty-text {
    font-size: 19px;
    color: var(--text-light);
    line-height: 1.6;
}

.empty-state .btn {
    margin-top: 20px;
}

/* ----- 16.5. 사용자 정보 (.user-info) ----- */
.site-header .user-info {
    font-size: 16px;
    color: var(--text-light);
    font-weight: 500;
    padding: 0 8px;
}

.site-header .nav-links .logout-link {
    font-size: 16px;
    color: var(--text-muted);
    margin-left: 0;
}

.site-header .nav-links .logout-link:hover {
    color: var(--danger);
    background: transparent;
}

/* ----- 18. 축하 애니메이션 (.confetti) ----- */
@keyframes confetti-fall {
    0% {
        transform: translateY(-100vh) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

@keyframes confetti-sway {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-20px);
    }
    75% {
        transform: translateX(20px);
    }
}

.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2000;
    overflow: hidden;
}

.confetti-piece {
    position: absolute;
    top: -20px;
    width: 12px;
    height: 12px;
    border-radius: 2px;
    animation: confetti-fall linear forwards;
}

.confetti-piece:nth-child(odd) {
    border-radius: 50%;
}

/* ----- 19. 새로운 그림 보기 버튼 (.refresh-btn) ----- */
.gallery-header {
    margin-bottom: 8px;
}

.gallery-header .back-button {
    font-size: 16px;
    color: var(--text-light);
    text-decoration: none;
    display: inline-block;
    margin-bottom: 8px;
}

.gallery-header .back-button:hover {
    color: var(--primary);
}

.gallery-header h2,
.gallery-header .gallery-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
    margin-bottom: 4px;
}

.gallery-header .gallery-desc {
    font-size: 20px;
    color: var(--text-light);
}

.refresh-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 17px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
    font-family: 'Noto Sans KR', sans-serif;
}

.refresh-btn:hover {
    background: var(--bg-alt);
}

.refresh-btn .refresh-icon {
    display: inline-block;
    transition: transform 0.3s;
}

.refresh-btn:hover .refresh-icon {
    transform: rotate(180deg);
}

/* ----- 페이지 타이틀 섹션 ----- */
.page-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 24px;
    letter-spacing: -0.3px;
}

.page-title .emoji {
    margin-right: 6px;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 17px;
    color: var(--text-light);
    margin-bottom: 20px;
}

.breadcrumb a {
    color: var(--primary);
}

.breadcrumb a:hover {
    text-decoration: underline;
}

.breadcrumb .sep {
    color: #ccc;
}

/* ----- 유틸리티 클래스 ----- */
.text-center {
    text-align: center;
}

.text-primary {
    color: var(--primary);
}

.text-success {
    color: var(--success);
}

.text-danger {
    color: var(--danger);
}

.mt-10 {
    margin-top: 10px;
}

.mt-20 {
    margin-top: 20px;
}

.mt-30 {
    margin-top: 30px;
}

.mb-10 {
    margin-bottom: 10px;
}

.mb-20 {
    margin-bottom: 20px;
}

.mb-30 {
    margin-bottom: 30px;
}

.hidden {
    display: none !important;
}

/* 테이블 수평 스크롤 래퍼 (모바일) */
.responsive-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ----- 20. 반응형 미디어쿼리 ----- */

/* 모바일 (768px 미만): 사이드바 숨김, 햄버거 메뉴 */
@media (max-width: 767px) {
    .mobile-topbar {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
    }

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

    .main-content {
        margin-left: 0;
        padding-top: var(--topbar-height);
    }

    .content-container {
        padding: 16px 14px;
    }

    .container {
        padding: 16px 14px;
    }

    body {
        font-size: 15px;
    }

    .category-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .category-card {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px 14px;
        text-align: left;
    }

    .category-card .icon,
    .category-card .category-icon {
        font-size: 28px;
        flex-shrink: 0;
    }

    .category-card .name,
    .category-card .category-name {
        font-size: 15px;
        font-weight: 600;
    }

    .today-stats h2 {
        font-size: 18px;
    }

    .today-stats .stats-row {
        gap: 12px;
    }

    .today-stats .stat .number {
        font-size: 22px;
    }

    .image-card img {
        height: 130px;
    }

    .image-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .grade-display .grade {
        font-size: 48px;
    }

    .grade-display .message {
        font-size: 15px;
    }

    .page-title {
        font-size: 18px;
    }

    .btn {
        padding: 8px 16px;
        font-size: 14px;
    }

    .btn-lg {
        padding: 12px 24px;
        font-size: 16px;
    }

    .comparison {
        grid-template-columns: 1fr;
    }

    .stat-card .number {
        font-size: 22px;
    }

    .stats-summary {
        gap: 12px;
    }

    .describe-layout {
        flex-direction: column;
    }

    .image-section {
        width: 100%;
    }

    .history-item {
        flex-wrap: wrap;
        gap: 8px;
        padding: 8px 0;
    }

    .history-item img {
        width: 48px;
        height: 36px;
    }

    .history-info .history-category {
        font-size: 14px;
    }

    .history-info .history-date {
        font-size: 12px;
    }

    .history-score {
        font-size: 14px;
    }

    .grade-badge {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
}

/* 태블릿 (768px+): 사이드바 항상 표시 */
@media (min-width: 768px) {
    .mobile-topbar {
        display: none;
    }

    .sidebar {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: none !important;
    }

    .category-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .image-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .describe-layout {
        flex-direction: row;
    }

    .image-section {
        flex: 0 0 55%;
    }
}

/* 데스크탑 (1024px+) */
@media (min-width: 1024px) {
    .category-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 12px;
    }

    .describe-layout {
        flex-direction: row;
    }

    .image-section {
        flex: 0 0 58%;
    }

    .image-card img {
        height: 220px;
    }

    .image-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
    }
}

/* 작은 모바일 (430px 이하) - iPhone 16 Pro 등 */
@media (max-width: 430px) {
    .content-container {
        padding: 14px 12px;
    }
    body {
        font-size: 14px;
    }
    .page-title {
        font-size: 17px;
    }
}

/* 인쇄 스타일 */
@media print {
    .sidebar,
    .mobile-topbar,
    .sidebar-overlay,
    .site-header,
    .site-footer,
    .btn,
    .loading-overlay,
    .confetti-container {
        display: none !important;
    }

    .main-content {
        margin-left: 0;
    }

    body {
        background: #fff;
        font-size: 16px;
    }

    .content-container,
    .container {
        max-width: 100%;
        padding: 0;
    }
}
