@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ============================================================
   리셋
   ============================================================ */
*, *::before, *::after {
    margin: 0; padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

/* ============================================================
   CSS Variables — Light (Indigo/Deep Blue)
   ============================================================ */
:root {
    --bg-primary:    #f1f3f8;
    --bg-secondary:  #ffffff;
    --bg-tertiary:   #f6f8fc;
    --bg-hover:      #eaecf5;
    --bg-card:       #edf0f9;
    --text-primary:   #16182a;
    --text-secondary: #5a5f7e;
    --text-muted:     #9298b8;
    --border-color:   #e2e5f0;
    --border-color-2: #d4d8ec;
    --accent-color:   #4f46e5;
    --accent-2:       #6366f1;
    --accent-light:   #eef0fe;
    --success-color:  #059669;
    --success-light:  #ecfdf5;
    --danger-color:   #dc2626;
    --danger-light:   #fef2f2;
    --shadow: rgba(79,70,229,0.08);
    --shadow-md: 0 4px 20px rgba(79,70,229,0.10);
    --color-learning: #0891b2;
    --color-wrong:    #ea580c;
    --color-safe:     #059669;
    --color-dialog-a: #4f46e5;
    --color-dialog-b: #7c3aed;
    --space-1: 6px; --space-2: 10px; --space-3: 16px;
    --font-s: 13px; --font-m: 16px; --font-l: 20px;
    --radius: 14px;
    --transition: 0.16s ease;
    --indigo-glow: 0 0 0 3px rgba(99,102,241,0.18);
}

/* ============================================================
   Dark Mode
   ============================================================ */
body.dark-mode, html.dark-mode {
    --bg-primary:    #0d0e1a;
    --bg-secondary:  #13152b;
    --bg-tertiary:   #101220;
    --bg-hover:      #1e2040;
    --bg-card:       #181a35;
    --text-primary:   #e8eaf6;
    --text-secondary: #8b90b8;
    --text-muted:     #565a7e;
    --border-color:   #1e2040;
    --border-color-2: #282c52;
    --accent-color:   #6366f1;
    --accent-2:       #818cf8;
    --accent-light:   rgba(99,102,241,0.14);
    --success-color:  #10b981;
    --success-light:  rgba(16,185,129,0.10);
    --danger-color:   #ef4444;
    --danger-light:   rgba(239,68,68,0.10);
    --shadow: rgba(0,0,0,0.3);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.45);
    --color-learning: #22d3ee;
    --color-wrong:    #fb923c;
    --color-safe:     #34d399;
    --color-dialog-a: #818cf8;
    --color-dialog-b: #a78bfa;
}

/* ============================================================
   Touch targets
   ============================================================ */
button, .icon-btn, .nav-btn, .option-btn, .action-btn, .popup-close, .mode-btn {
    min-height: 44px;
}
.icon-btn, .nav-btn { min-width: 44px; }

/* ============================================================
   Base
   ============================================================ */
body {
    font-family: 'Outfit', 'Malgun Gothic', -apple-system, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    overflow-x: hidden;
    padding-bottom: 70px;
    transition: background-color var(--transition), color var(--transition);
}

/* ============================================================
   Header (슬림 + 인디고)
   ============================================================ */
.header {
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    padding: 10px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 12px var(--shadow);
    z-index: 100;
}

.header-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.2px;
}

/* 헤더 타이틀에 인디고 포인트 */
.header-title::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--accent-color);
    border-radius: 2px;
    margin-right: 8px;
    vertical-align: middle;
    margin-bottom: 1px;
}

.header-icons { display: flex; gap: 5px; }

.icon-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    width: 34px;
    height: 34px;
    border-radius: 9px;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    color: var(--text-secondary);
}
.icon-btn:active { background: var(--accent-light); color: var(--accent-color); transform: scale(0.93); }

/* ============================================================
   Mode Selector (가로 탭)
   ============================================================ */
.mode-selector {
    padding: 8px 14px;
    display: flex;
    gap: 6px;
}

.mode-btn {
    flex: 1;
    padding: 8px 4px;
    background: var(--bg-secondary);
    border: 1.5px solid var(--border-color-2);
    border-radius: var(--radius);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    color: var(--text-secondary);
    font-family: 'Outfit', sans-serif;
    min-height: 52px;
}
.mode-btn.active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
    box-shadow: 0 3px 12px rgba(79,70,229,0.28);
}
.mode-btn:active { transform: scale(0.95); }
.mode-icon { font-size: 18px; line-height: 1; }

/* ============================================================
   Control Bar
   ============================================================ */
.control-bar {
    padding: 8px 14px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 7px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.control-bar::-webkit-scrollbar { display: none; }

.control-chip {
    padding: 6px 13px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color-2);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    flex-shrink: 0;
    color: var(--text-secondary);
    transition: all var(--transition);
    font-family: 'Outfit', sans-serif;
}
.control-chip.primary {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(79,70,229,0.22);
}

/* ============================================================
   Card Area (세로 확장)
   ============================================================ */
.card-area {
    padding: 14px;
    min-height: calc(100vh - 260px);
    display: flex;
    align-items: center;
}

.flash-card {
    width: 100%;
    background: var(--bg-secondary);
    border-radius: 18px;
    padding: 44px 24px 36px;
    min-height: 440px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    position: relative;
    touch-action: pan-y;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.flash-card:focus-within { border-color: var(--accent-color); }

.card-info {
    position: absolute;
    top: 14px;
    left: 14px;
    right: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11.5px;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

.card-word {
    font-size: 48px;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 18px;
    word-break: keep-all;
    line-height: 1.15;
    cursor: pointer;
    letter-spacing: -2px;
    transition: color var(--transition);
}
.card-word:active { color: var(--accent-color); }

.card-meaning {
    font-size: 26px;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.45;
    font-weight: 400;
    letter-spacing: -0.2px;
}

/* ============================================================
   Quiz Options
   ============================================================ */
.quiz-options {
    display: grid;
    grid-template-columns: 1fr;
    gap: 9px;
    width: 100%;
    margin-top: 18px;
}

.quiz-btn {
    padding: 17px 16px;
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1.5px solid var(--border-color-2);
    border-radius: var(--radius);
    cursor: pointer;
    text-align: left;
    font-family: 'Outfit', sans-serif;
    transition: all var(--transition);
    line-height: 1.4;
}
body.dark-mode .quiz-btn { color: var(--text-primary) !important; }
.quiz-btn:active { transform: scale(0.98); }
.quiz-btn.correct {
    background: var(--success-light) !important;
    color: var(--success-color) !important;
    border-color: var(--success-color) !important;
    font-weight: 600;
}
.quiz-btn.wrong {
    background: var(--danger-light) !important;
    color: var(--danger-color) !important;
    border-color: var(--danger-color) !important;
    font-weight: 600;
}

/* ============================================================
   Progress Bar
   ============================================================ */
.progress-bar {
    position: absolute;
    bottom: 0; left: 0;
    width: 100%;
    height: 4px;
    background: var(--bg-card);
    border-radius: 0 0 18px 18px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-color), var(--accent-2));
    width: 0%;
    transition: width 0.3s;
}

/* ============================================================
   Bottom Nav
   ============================================================ */
.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--bg-secondary);
    padding: 7px;
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -4px 16px var(--shadow);
    display: flex;
    justify-content: space-around;
    z-index: 100;
}

.nav-btn {
    flex: 1;
    padding: 7px;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    border-radius: 10px;
    transition: all 0.18s;
    color: var(--text-secondary);
}
.nav-btn:active { background: var(--accent-light); transform: scale(0.9); }

/* ============================================================
   Popup (bottom sheet)
   ============================================================ */
.popup-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(8,9,20,0.6);
    backdrop-filter: blur(6px);
    z-index: 200;
    align-items: flex-end;
}
.popup-overlay.show { display: flex; }

.popup {
    background: var(--bg-secondary);
    border-radius: 20px 20px 0 0;
    padding: 22px;
    width: 100%;
    max-height: 70vh;
    overflow-y: auto;
    animation: slideUp 0.26s ease;
    border-top: 1px solid var(--border-color);
}
@keyframes slideUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}
.popup-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}
.popup-close {
    font-size: 22px;
    border: none;
    background: var(--bg-card);
    border-radius: 8px;
    width: 30px;
    height: 30px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all var(--transition);
}
.popup-close:active { background: var(--bg-hover); }

/* ============================================================
   Settings
   ============================================================ */
.setting-group { margin-bottom: 20px; }
.setting-label {
    font-weight: 600;
    font-size: 11.5px;
    margin-bottom: 9px;
    display: block;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.btn-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 7px;
}

.option-btn {
    padding: 11px 8px;
    background: var(--bg-tertiary);
    border: 1.5px solid var(--border-color-2);
    border-radius: 10px;
    font-size: 13px;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-secondary);
    font-family: 'Outfit', sans-serif;
    transition: all var(--transition);
}
.option-btn.active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
    box-shadow: 0 2px 8px rgba(79,70,229,0.25);
}
.option-btn:active { transform: scale(0.96); }

/* ============================================================
   Checkbox Group
   ============================================================ */
.checkbox-group { display: flex; flex-wrap: wrap; gap: 9px; }
.checkbox-item {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 8px 13px;
    background: var(--bg-tertiary);
    border-radius: 20px;
    cursor: pointer;
    border: 1px solid var(--border-color);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--transition);
}

.checkbox {
    width: 17px;
    height: 17px;
    border: 2px solid var(--border-color-2);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.checkbox.checked {
    background: var(--accent-color);
    border-color: var(--accent-color);
}
.checkbox.checked::after {
    content: '✓';
    color: white;
    font-size: 11px;
    font-weight: 700;
}

/* ============================================================
   Range Input
   ============================================================ */
.range-input {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
}
.range-input input {
    flex: 1;
    padding: 11px;
    background: var(--bg-tertiary);
    border: 1.5px solid var(--border-color-2);
    border-radius: 10px;
    font-size: 15px;
    text-align: center;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    outline: none;
    transition: all var(--transition);
}
.range-input input:focus {
    border-color: var(--accent-color);
    box-shadow: var(--indigo-glow);
}

/* ============================================================
   Modal (full overlay)
   ============================================================ */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(8,9,20,0.7);
    backdrop-filter: blur(7px);
    z-index: 300;
    padding: 20px;
    overflow-y: auto;
}
.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-content {
    background: var(--bg-secondary);
    border-radius: 18px;
    padding: 22px;
    width: 100%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    animation: modalIn 0.2s ease;
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.97) translateY(8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.modal-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

/* ============================================================
   Stats
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 9px;
    margin: 12px 0;
}
.stat-card {
    background: var(--bg-tertiary);
    padding: 13px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid var(--border-color);
}
.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent-color);
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: -0.5px;
}
.stat-label {
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 2px;
    font-weight: 500;
}

/* ============================================================
   Report Row
   ============================================================ */
.report-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 11px;
    background: var(--bg-tertiary);
    margin-bottom: 7px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
}
.report-word { flex: 1; }
.report-word-eng { font-weight: 600; margin-bottom: 2px; font-size: 14.5px; }
.report-word-kor { font-size: 12.5px; color: var(--text-secondary); }

.speaker-btn {
    width: 34px;
    height: 34px;
    background: var(--accent-light);
    color: var(--accent-color);
    border: none;
    border-radius: 9px;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 10px;
    transition: all var(--transition);
}
.speaker-btn:active { transform: scale(0.91); }
body.dark-mode .speaker-btn {
    background: rgba(99,102,241,0.15);
    color: var(--accent-color);
}

/* ============================================================
   Action Button
   ============================================================ */
.action-btn {
    width: 100%;
    padding: 15px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 15.5px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 12px;
    font-family: 'Outfit', sans-serif;
    transition: all var(--transition);
    box-shadow: 0 4px 14px rgba(79,70,229,0.28);
}
.action-btn:active { transform: scale(0.98); filter: brightness(0.94); }

.text-wrong   { color: var(--danger-color);  font-weight: 700; }
.text-correct { color: var(--success-color); font-weight: 700; }

/* ============================================================
   Slider
   ============================================================ */
.slider-container { margin: 12px 0; }
.slider {
    width: 100%;
    height: 38px;
    -webkit-appearance: none;
    background: var(--bg-card);
    outline: none;
    border-radius: 20px;
    border: 1px solid var(--border-color);
}
.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 26px;
    height: 26px;
    background: var(--accent-color);
    cursor: pointer;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(79,70,229,0.3);
}
.slider-value {
    text-align: center;
    font-size: 20px;
    font-weight: 700;
    color: var(--accent-color);
    margin-top: 7px;
    font-family: 'JetBrains Mono', monospace;
}

/* ============================================================
   Fullscreen Study
   ============================================================ */
.study-fullscreen-btn {
    position: fixed;
    bottom: 90px; right: 14px;
    width: 50px; height: 50px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 21px;
    box-shadow: 0 4px 16px rgba(79,70,229,0.38);
    cursor: pointer;
    z-index: 99;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}
.study-fullscreen-btn:active { transform: scale(0.9); }

.shadow-loop-btn {
    position: fixed;
    bottom: 150px; right: 14px;
    width: 50px; height: 50px;
    background: rgba(0,0,0,0.35);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 21px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    cursor: pointer;
    z-index: 99;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.shadow-loop-btn:active { transform: scale(0.92); }
.shadow-loop-btn.on { background: var(--accent-color); box-shadow: 0 4px 14px rgba(79,70,229,0.35); }

body.study-fullscreen .header,
body.study-fullscreen .mode-selector,
body.study-fullscreen .control-bar,
body.study-fullscreen .bottom-nav { display: none !important; }
body.study-fullscreen { padding-bottom: 0; }
body.study-fullscreen .card-area { padding: 0; min-height: 100vh; display: flex; align-items: center; justify-content: center; }
body.study-fullscreen .flash-card { min-height: 100vh; border-radius: 0; border: none; }
body.study-fullscreen .study-fullscreen-btn { bottom: 16px; }
body.study-fullscreen .shadow-loop-btn { bottom: 80px; }

/* ============================================================
   Fullscreen Modebar
   ============================================================ */
.fs-modebar {
    position: fixed;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    display: flex;
    gap: 7px;
    padding: 7px 9px;
    border-radius: 18px;
    background: rgba(8,9,20,0.55);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 9999;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
body:not(.study-fullscreen) .fs-modebar { display: none !important; }
.fs-modebar.hidden { display: none !important; }
.fs-modebtn {
    min-height: 34px;
    border: 1px solid rgba(255,255,255,0.16);
    background: rgba(255,255,255,0.08);
    color: #fff;
    padding: 5px 11px;
    border-radius: 11px;
    font-size: 12.5px;
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
    transition: all var(--transition);
}
.fs-modebtn:active { transform: scale(0.97); }
.fs-modebtn.active { background: rgba(255,255,255,0.20); border-color: rgba(255,255,255,0.28); }

/* ============================================================
   Scrollbar
   ============================================================ */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color-2); border-radius: 99px; }

/* ============================================================
   Quiz Count Chip (+-버튼 높이 정상화)
   ============================================================ */
.quiz-count-chip {
    display: flex;
    align-items: center;
    gap: 6px;
}
.quiz-count-btn {
    background: none;
    border: none;
    font-size: 14px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    display: flex;
    align-items: center;
    min-height: unset;
    color: var(--text-secondary);
}
.quiz-count-btn:active { transform: scale(0.88); }
