/* TOPIK 단어장 - Dark Mode (Anki Style) */

:root {
    --bg: #0D0D0D;
    --card-bg: #1A1A1A;
    --text: #FFFFFF;
    --text-muted: #888888;
    --border: #333333;
    --again: #D32F2F;
    --hard: #F57C00;
    --good: #388E3C;
    --easy: #1976D2;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans KR', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.4;
}

.app-container {
    max-width: 500px;
    margin: 0 auto;
    padding: 12px;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* 헤더 */
.header {
    text-align: center;
    padding: 12px 0;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.header h1 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}

/* ============================================================
   공통 섹션 구조: top-bar + section-content + bottom-bar
   ============================================================ */

.filter-section,
.card-section,
.complete-section {
    flex: 1;
    display: none;
    flex-direction: column;
}

.filter-section {
    display: flex;
}

.card-section.active,
.complete-section.active {
    display: flex;
}

/* 상단 바 (모든 화면 동일 높이) */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    padding: 0 12px;
    margin-bottom: 8px;
    flex-shrink: 0;
    position: relative;
}

.placeholder {
    height: 36px;
}

.back-btn {
    position: absolute;
    left: 0;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
}

.back-btn:hover {
    border-color: var(--text);
    color: var(--text);
}

#progress {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* 콘텐츠 영역 */
.section-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 4px 0;
    overflow: hidden;
}

/* 하단 버튼 영역 (모든 화면 동일) */
.bottom-bar {
    flex-shrink: 0;
    padding: 8px 0;
    min-height: 60px;
}

.action-btn {
    display: none;
    width: 100%;
    padding: 14px;
    background: var(--text);
    color: var(--bg);
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
}

.action-btn:disabled {
    background: var(--border);
    color: var(--text-muted);
    cursor: not-allowed;
}

.action-btn.active {
    display: block;
}

/* 첫 화면과 완료 화면의 버튼은 항상 표시 */
.filter-section .action-btn,
.complete-section .action-btn {
    display: block;
}

/* ============================================================
   첫 화면 (필터 선택)
   ============================================================ */

.intro-text {
    text-align: center;
    margin-bottom: 12px;
    padding: 10px;
    background: var(--card-bg);
    border-radius: 8px;
}

.intro-text p {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 2px;
    line-height: 1.4;
}

.intro-text p:last-child {
    margin-bottom: 0;
}

.filter-row {
    margin-bottom: 12px;
}

.filter-row label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-align: center;
}

.btn-group {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.select-btn {
    flex: 1;
    max-width: 100px;
    padding: 12px 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
}

.select-btn.active {
    background: var(--text);
    color: var(--bg);
    border-color: var(--text);
}

/* 1-6급 버튼 그리드 */
.level-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    max-width: 320px;
    margin: 0 auto;
}

.level-grid .select-btn {
    max-width: none;
    padding: 10px 8px;
    font-weight: 600;
}

.info-text {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 6px;
}

/* ============================================================
   카드 화면
   ============================================================ */

.card-container {
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 4px;
}

.card {
    width: 100%;
    height: 100%;
    background: transparent;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    text-align: center;
    padding: 20px;
    padding-top: 10px;
    cursor: pointer;
}

/* 카드 앞면 */
.card-front {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.card.flipped .card-front {
    display: none;
}

.word-korean {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.word-info {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.word-pronunciation {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.audio-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: transparent;
    color: var(--text);
    font-size: 1.2rem;
    cursor: pointer;
    margin-bottom: 16px;
}

.audio-btn:hover {
    border-color: var(--text);
}


/* 카드 뒷면 */
.card-back {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.card.flipped .card-back {
    display: flex;
}

.translation-word {
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 12px;
}

.translation-def {
    font-size: 1rem;
    color: var(--text);
    line-height: 1.5;
    max-width: 90%;
}

/* 하단 버튼 영역 - 카드 화면 */
.bottom-bar .action-btn {
    background: var(--card-bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.bottom-bar .action-btn:not(:disabled):hover {
    border-color: var(--text);
}

/* 평가 버튼 */
.rating-buttons {
    display: none;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    width: 100%;
}

.rating-buttons.active {
    display: grid;
}

.rating-btn {
    padding: 10px 6px;
    min-height: 48px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
}

.rating-label {
    font-weight: 600;
    font-size: 0.8rem;
    margin-bottom: 2px;
}

.rating-interval {
    font-size: 0.65rem;
    opacity: 0.85;
}

.rating-btn.again { background: var(--again); }
.rating-btn.hard { background: var(--hard); }
.rating-btn.good { background: var(--good); }
.rating-btn.easy { background: var(--easy); }

/* ============================================================
   완료 화면
   ============================================================ */

.complete-section .section-content {
    justify-content: center;
    align-items: center;
}

.complete-section h2 {
    font-size: 1.3rem;
    margin-bottom: 16px;
}

.complete-stats {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    width: 100%;
    max-width: 280px;
}

.complete-stats p {
    font-size: 0.9rem;
    margin-bottom: 6px;
    color: var(--text-muted);
}

.complete-stats strong {
    color: var(--text);
}

.complete-message {
    font-size: 0.85rem;
    color: var(--good);
    text-align: center;
    margin-top: 12px;
    padding: 10px;
    background: rgba(56, 142, 60, 0.1);
    border-radius: 8px;
    display: none;
    max-width: 280px;
}

.complete-message.show {
    display: block;
}

/* ============================================================
   반응형
   ============================================================ */

@media (max-height: 600px) {
    .header {
        padding: 4px 0;
    }

    .header h1 {
        font-size: 0.9rem;
    }

    .top-bar {
        height: 30px;
    }

    .word-korean {
        font-size: 2rem;
    }

    .card {
        padding: 12px;
        padding-top: 10px;
    }

    .audio-btn {
        width: 36px;
        height: 36px;
        font-size: 1rem;
        margin-bottom: 8px;
    }

    .action-btn {
        padding: 12px;
    }

    .rating-btn {
        padding: 8px 4px;
        min-height: 44px;
    }
}
