/* ── Victory Strategy 다크 테마 ── */

:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #16213e;
    --bg-input: #0f3460;
    --bg-hover: #1e2a4a;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0b0;
    --text-muted: #6c6c80;
    --accent: #00d2ff;
    --accent-hover: #00b8e6;
    --danger: #ff6b6b;
    --danger-hover: #ee5a5a;
    --success: #51cf66;
    --border: #2a2a40;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* ── 라이트(일반) 테마 — html[data-theme="light"] 일 때 변수만 덮어씀 ──
   사이트 전체가 var(--…) 를 쓰므로 변수만 바꾸면 모든 화면이 함께 전환된다.
   accent 를 배경으로 쓰는 버튼은 글자색이 --bg-primary(반대 톤)라 대비가 유지됨. */
html[data-theme="light"] {
    --bg-primary: #f1f4f9;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #eef2f8;
    --bg-hover: #e4eaf3;
    --text-primary: #1b2330;
    --text-secondary: #46546a;
    --text-muted: #8a93a4;
    --accent: #0277a8;
    --accent-hover: #015d83;
    --danger: #d64545;
    --danger-hover: #b83a3a;
    --success: #2b8a3e;
    --border: #d6dde8;
    --shadow: 0 2px 10px rgba(20,30,60,0.08);
}
/* 라이트 보정: 인라인 코드 가독성 + 코드블록 라벨바는 어둡게 유지(코드블록 본문이 다크라서) */
html[data-theme="light"] .md-code { background: rgba(2,119,168,0.10); color: #0a5f82; }
html[data-theme="light"] .md-pre[data-lang]::before { background: #161c2e; color: #9aa3b8; border-bottom-color: #2a3350; }
/* 테마 토글 버튼 */
.theme-toggle { font-size: 15px; line-height: 1.1; }

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Malgun Gothic', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ── 로그인 ── */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}
.login-box {
    background: var(--bg-card);
    padding: 40px;
    border-radius: var(--radius);
    width: 100%;
    max-width: 360px;
    text-align: center;
    box-shadow: var(--shadow);
}
.login-box h1 {
    color: var(--accent);
    font-size: 28px;
    margin-bottom: 8px;
}
.login-sub {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 14px;
}

/* ── 권한 체크박스 ── */
.perm-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}
.perm-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
}
.perm-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

/* ── 레이아웃 ── */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.header h1 {
    font-size: 20px;
    color: var(--accent);
}
.header h1 a { color: var(--accent); }
.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.header-actions .btn-ghost { padding: 5px 12px; font-size: 13px; }
.header-user {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 600;
    padding-left: 14px;
    margin-left: 6px;
    border-left: 1px solid var(--border);
}
/* 헤더 사용자 메뉴 드롭다운 (아이디 클릭 → 로그아웃/비밀번호 변경) */
.user-dropdown {
    position: absolute; right: 0; top: calc(100% + 8px);
    min-width: 168px; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px; z-index: 1000; display: none;
}
.user-dropdown.open { display: block; }
.user-dropdown a, .user-dropdown button {
    display: block; width: 100%; box-sizing: border-box; text-align: left;
    padding: 9px 12px; font-size: 14px; color: var(--text-primary); background: none;
    border: 0; border-radius: 8px; cursor: pointer; text-decoration: none; font-family: inherit;
}
.user-dropdown a:hover, .user-dropdown button:hover { background: var(--bg-hover); color: var(--text-primary); }
.um-caret { font-size: 10px; color: var(--text-muted); margin-left: 3px; }

/* 상하 패딩만 지정 — 좌우는 .container(0 20px)를 덮지 않게(모바일 좌우 여백 유지) */
.main { padding-top: 24px; padding-bottom: 24px; }

/* ── 버튼 ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    text-decoration: none;
    line-height: 1.4;
}
.btn-primary { background: var(--accent); color: var(--bg-primary); font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); color: var(--bg-primary); }
.btn-secondary { background: var(--bg-input); color: var(--text-primary); }
.btn-secondary:hover { background: var(--bg-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }
.btn-ghost { background: transparent; color: var(--text-secondary); padding: 6px 10px; }
.btn-ghost:hover { color: var(--text-primary); }

/* ── 폼 ── */
.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 500;
}
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
}
.form-group textarea {
    min-height: 100px;
    resize: vertical;
}
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}
.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

/* ── 알림 ── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
}
.alert-error { background: rgba(255,107,107,0.15); color: var(--danger); border: 1px solid rgba(255,107,107,0.3); }
.alert-success { background: rgba(81,207,102,0.15); color: var(--success); border: 1px solid rgba(81,207,102,0.3); }

/* ── 검색/필터 바 ── */
.filter-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}
.filter-bar select,
.filter-bar input[type="text"],
.filter-bar input[type="number"] {
    padding: 8px 12px;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
}
.filter-bar select { min-width: 140px; }
.filter-bar input[type="text"] { flex: 1; min-width: 180px; }
.filter-bar select:focus,
.filter-bar input:focus { outline: none; border-color: var(--accent); }

/* 문제 번호 이동 */
.jump-box { display: flex; gap: 6px; align-items: center; flex: 0 0 auto; }
.filter-bar input[type="number"] {
    width: 66px;
    padding: 8px 8px;
    text-align: center;
    -moz-appearance: textfield;
}
.filter-bar input[type="number"]::-webkit-inner-spin-button,
.filter-bar input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* ── 테이블 ── */
.table-wrap {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}
table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}
thead th {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    text-align: left;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-hover); }
.col-no { width: 50px; text-align: center; color: var(--text-muted); }
.col-exam { width: 180px; text-align: left; }
.col-exam-val { width: 180px; text-align: left; }
.col-review { width: 70px; }
.col-question { word-break: break-word; overflow-wrap: break-word; }
.col-actions { width: 80px; text-align: center; white-space: nowrap; }
.exam-subject-sep { color: var(--text-muted); margin: 0 2px; }
.truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
    display: block;
}
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state p { font-size: 16px; margin-bottom: 16px; }

/* ── 페이징 ── */
.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 24px;
    flex-wrap: wrap;
}
.pagination a,
.pagination span {
    padding: 6px 12px;
    border-radius: var(--radius);
    font-size: 14px;
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.pagination a:hover { border-color: var(--accent); color: var(--accent); }
.pagination .active {
    background: var(--accent);
    color: var(--bg-primary);
    border-color: var(--accent);
    font-weight: 600;
}

/* ── 상세 보기 ── */
.detail-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow);
}
.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}
.detail-title { font-size: 20px; font-weight: 600; }
.detail-meta {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}
.meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}
.meta-label { color: var(--text-muted); }
.detail-section {
    margin-bottom: 20px;
}
.detail-section h3 {
    font-size: 13px;
    color: var(--accent);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.detail-section .content {
    background: var(--bg-secondary);
    padding: 16px;
    border-radius: var(--radius);
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.7;
}
.detail-section .content.answer-wrong {
    border-left: 3px solid var(--danger);
}
.detail-section .content.answer-correct {
    border-left: 3px solid var(--success);
}
.detail-actions {
    display: flex;
    gap: 12px;
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* ── 보기 입력 (폼) ── */
.choices-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.choices-label {
    min-width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: var(--bg-input);
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}
.choices-input-row input.choice-input {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
}
.choices-input-row input.choice-input:focus {
    outline: none;
    border-color: var(--accent);
}

/* ── 보기 카드 (상세) ── */
.choice-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.choice-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    transition: border-color 0.2s;
}
.choice-item.is-answer {
    border-color: var(--success);
    background: rgba(81,207,102,0.08);
}
.choice-letter {
    min-width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: var(--bg-input);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}
.choice-item.is-answer .choice-letter {
    background: var(--success);
    color: var(--bg-primary);
}
.choice-text {
    font-size: 14px;
    line-height: 1.6;
    padding-top: 3px;
}

/* ── 이미지 붙여넣기 (폼) ── */
.image-paste-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.image-paste-area:focus,
.image-paste-area:hover {
    border-color: var(--accent);
    background: rgba(0,210,255,0.03);
    outline: none;
}
.image-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 14px;
}
.image-paste-icon {
    font-size: 32px;
    opacity: 0.6;
}
.image-preview {
    position: relative;
    display: inline-block;
    max-width: 100%;
}
.image-preview img {
    max-width: 100%;
    max-height: 400px;
    border-radius: var(--radius);
    display: block;
}
.image-remove-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: var(--danger);
    color: #fff;
    font-size: 18px;
    line-height: 28px;
    text-align: center;
    cursor: pointer;
    padding: 0;
    transition: background 0.2s;
}
.image-remove-btn:hover {
    background: var(--danger-hover);
}

/* ── 이미지 표시 (상세) ── */
.detail-image {
    background: var(--bg-secondary);
    padding: 16px;
    border-radius: var(--radius);
    text-align: center;
}
.detail-image img {
    max-width: 100%;
    max-height: 600px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: opacity 0.2s;
}
.detail-image img:hover {
    opacity: 0.85;
}

/* ── 한/영 토글 ── */
.lang-toggle {
    display: inline-flex;
    gap: 0;
    margin-bottom: 20px;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}
.lang-btn {
    padding: 7px 20px;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.lang-btn:not(:last-child) {
    border-right: 1px solid var(--border);
}
.lang-btn:hover { color: var(--text-primary); }
.lang-btn.active {
    background: var(--accent);
    color: var(--bg-primary);
}

/* ── 리스트 한/영 토글 ── */
.list-lang-toggle {
    display: inline-block;
    padding: 2px 8px;
    margin-right: 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    vertical-align: middle;
    flex-shrink: 0;
}
.list-lang-toggle:hover { border-color: var(--accent); color: var(--accent); }
.list-lang-toggle.active {
    background: var(--accent);
    color: var(--bg-primary);
    border-color: var(--accent);
}

/* ── 퀴즈 토글 (목록) ── */
.col-quiz { white-space: nowrap; }
.quiz-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    padding-top: 8px;
    max-width: 100%;
    min-width: 0;
}
.quiz-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    padding: 0;
    line-height: 32px;
    text-align: center;
    flex-shrink: 0;
}
.quiz-btn.has-text {
    width: 100%;
    height: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    text-align: left;
    line-height: 1.4;
    white-space: normal;
    flex-shrink: 1;
}
.quiz-btn-letter {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    line-height: 24px;
    text-align: center;
    border-radius: 4px;
    background: var(--bg-input);
    font-size: 12px;
    font-weight: 700;
}
.quiz-btn-text {
    font-weight: 400;
    font-size: 13px;
    color: var(--text-primary);
    white-space: normal;
    word-break: break-word;
    min-width: 0;
}
.quiz-btn:hover { border-color: var(--accent); color: var(--accent); }
.quiz-btn.has-text:hover .quiz-btn-letter { background: var(--accent); color: var(--bg-primary); }
.quiz-btn.selected {
    background: var(--accent);
    color: var(--bg-primary);
    border-color: var(--accent);
}
.quiz-btn.selected .quiz-btn-letter { background: rgba(0,0,0,0.2); color: #fff; }
.quiz-btn.selected .quiz-btn-text { color: var(--bg-primary); }
.quiz-btn.correct {
    background: var(--success);
    color: var(--bg-primary);
    border-color: var(--success);
}
.quiz-btn.correct .quiz-btn-letter { background: rgba(0,0,0,0.2); color: #fff; }
.quiz-btn.correct .quiz-btn-text { color: var(--bg-primary); }
.quiz-btn.wrong {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}
.quiz-btn.wrong .quiz-btn-letter { background: rgba(0,0,0,0.2); color: #fff; }
.quiz-btn.wrong .quiz-btn-text { color: #fff; }
.quiz-btn.answer-reveal {
    border-color: var(--success);
    color: var(--success);
    background: rgba(81,207,102,0.15);
}
.quiz-btn.answer-reveal .quiz-btn-text { color: var(--success); }
.quiz-btn:disabled {
    cursor: default;
    opacity: 0.8;
}
.quiz-result {
    font-size: 20px;
    font-weight: 700;
    margin-left: 6px;
    min-width: 24px;
    text-align: center;
}
.quiz-review {
    font-size: 13px;
    color: var(--text-muted);
}
.quiz-detail-btn {
    font-size: 12px;
    padding: 2px 10px;
    flex-shrink: 0;
    background: #f5c842;
    color: var(--bg-primary);
    border-color: #f5c842;
}
.quiz-detail-btn:hover {
    background: #f5c842;
    color: var(--bg-primary);
}
.quiz-result.is-correct { color: var(--success); }
.quiz-result.is-wrong { color: var(--danger); }
.quiz-row.submitted .quiz-btn:not(.selected):not(.answer-reveal) {
    opacity: 0.3;
}

/* ── 복습 배지 (목록) ── */
.review-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    border-radius: 14px;
    font-size: 13px;
    font-weight: 600;
    background: var(--bg-secondary);
    color: var(--text-muted);
}
.review-badge.reviewed {
    background: rgba(81,207,102,0.15);
    color: var(--success);
}

/* ── 복습 박스 (상세) ── */
.review-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}
.review-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.review-label {
    font-size: 13px;
    color: var(--text-muted);
}
.review-count {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
    line-height: 1;
}
.review-date {
    font-size: 12px;
    color: var(--text-muted);
}
.review-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}
.btn-review {
    background: var(--success);
    color: var(--bg-primary);
    font-weight: 600;
    padding: 8px 18px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}
.btn-review:hover {
    background: #3db856;
}
.btn-review.clicked {
    animation: reviewPulse 0.4s ease;
}
@keyframes reviewPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* ── 통계 바 ── */
.stats-bar {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.stat-item {
    font-size: 14px;
    color: var(--text-secondary);
}
.stat-item strong {
    color: var(--accent);
    font-size: 18px;
    margin-right: 4px;
}

/* ── 관리 페이지 탭 ── */
.admin-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 24px;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    width: fit-content;
}
.admin-tab {
    padding: 10px 24px;
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.15s;
    border-right: 1px solid var(--border);
}
.admin-tab:last-child {
    border-right: none;
}
.admin-tab:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}
.admin-tab.active {
    background: var(--accent);
    color: var(--bg-primary);
}

/* ── 카테고리 카드 (아코디언) ── */
.category-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
}
.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    cursor: pointer;
    transition: background 0.15s;
    gap: 12px;
}
.category-header:hover {
    background: var(--bg-hover);
}
.category-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
}
.category-arrow {
    font-size: 12px;
    color: var(--text-muted);
    transition: transform 0.2s;
    display: inline-block;
}
.category-count {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-secondary);
    padding: 2px 10px;
    border-radius: 12px;
}
.category-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}
.category-body {
    padding: 0 20px 20px 20px;
    border-top: 1px solid var(--border);
    padding-top: 16px;
}

/* ── 과목 목록 ── */
.subject-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.subject-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border-radius: 6px;
    border: 1px solid var(--border);
    gap: 12px;
}
.subject-name {
    font-size: 14px;
    color: var(--text-primary);
}
.subject-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* ── 수정 모달 ── */
.edit-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}
.edit-modal-content {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 28px;
    min-width: 360px;
    max-width: 90vw;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.edit-modal-content h3 {
    font-size: 18px;
    margin-bottom: 16px;
    color: var(--accent);
}

/* ── 홈 화면 ── */
.home-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 24px;
}
.home-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}
.home-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    min-height: 120px;
    border: 1px solid var(--border);
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
    box-shadow: var(--shadow);
}
.home-card:hover {
    border-color: var(--accent);
    background: var(--bg-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.home-card-name {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
    word-break: break-word;
}
.home-card-count {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 12px;
}
.home-card:hover .home-card-count {
    color: var(--accent);
}
.home-card-all {
    border-color: var(--accent);
    background: rgba(0,210,255,0.05);
}
.home-card-all .home-card-name {
    color: var(--accent);
}

/* ── 별표(중요) 버튼 ── */
.btn-star {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0;
    line-height: 1;
    transition: color 0.2s, transform 0.2s;
}
.btn-star:hover {
    transform: scale(1.2);
}
.btn-star.starred {
    color: #ffc107;
}
.list-star {
    color: #ffc107;
    font-size: 14px;
    margin-right: 4px;
}
.btn-star-filter {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 16px;
    padding: 4px 10px;
    border-radius: var(--radius);
    text-decoration: none;
    transition: all 0.2s;
}
.btn-star-filter:hover {
    color: #ffc107;
    border-color: #ffc107;
}
.btn-star-active {
    background: rgba(255,193,7,0.15);
    border: 1px solid #ffc107;
    color: #ffc107;
    font-size: 16px;
    padding: 4px 10px;
    border-radius: var(--radius);
    text-decoration: none;
}

/* ── 오답(자동) 마커 / 필터 ── */
.wrong-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 11px;
    background: rgba(255,107,107,0.15);
    color: var(--danger);
    border: 1px solid rgba(255,107,107,0.4);
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
}
.btn-wrong-filter {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 16px;
    padding: 4px 10px;
    border-radius: var(--radius);
    text-decoration: none;
    transition: all 0.2s;
}
.btn-wrong-filter:hover {
    color: var(--danger);
    border-color: var(--danger);
}
.btn-wrong-active {
    background: rgba(255,107,107,0.15);
    border: 1px solid var(--danger);
    color: var(--danger);
    font-size: 16px;
    padding: 4px 10px;
    border-radius: var(--radius);
    text-decoration: none;
}

/* ── 카드 모드 (1문제씩) ── */
.card-mode {
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.card-progress {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}
.card-counter {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 600;
}
.card-counter span { color: var(--accent); }
.card-nav-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
}
.card-nav-btn:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--bg-hover);
}
.card-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}
.card-stage {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    min-height: 280px;
    overflow: hidden;
}
.card-loading {
    text-align: center;
    color: var(--text-muted);
    padding: 60px 20px;
    font-size: 14px;
}
.card-footer {
    margin-top: 12px;
    display: flex;
    gap: 8px;
}
.card-footer .btn-block { flex: 1; }

.q-card { animation: cardIn 0.18s ease; }
.q-card.swipe-left { animation: swipeOutLeft 0.18s ease forwards; }
.q-card.swipe-right { animation: swipeOutRight 0.18s ease forwards; }
@keyframes cardIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes swipeOutLeft {
    to { opacity: 0; transform: translateX(-40px); }
}
@keyframes swipeOutRight {
    to { opacity: 0; transform: translateX(40px); }
}

.q-card-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.q-card-meta {
    flex: 1;
    font-size: 12px;
    color: var(--text-muted);
}
.q-card-meta strong { color: var(--text-secondary); font-weight: 600; }
.q-card-question {
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-primary);
    margin-bottom: 16px;
    white-space: pre-wrap;
    word-break: break-word;
}
.q-card-image {
    margin: 12px 0;
    text-align: center;
}
.q-card-image img {
    max-width: 100%;
    max-height: 320px;
    border-radius: var(--radius);
    cursor: pointer;
}
.q-card-choices {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}
.q-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    align-items: center;
}
.q-card-actions .quiz-result {
    margin-left: 0;
    margin-right: 4px;
}
.q-card-actions .quiz-review {
    margin-left: auto;
}
.q-card-explain {
    margin-top: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 14px 16px;
    border-left: 3px solid var(--accent);
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.7;
    font-size: 14px;
    display: none;
}
.q-card-explain.show { display: block; }
.q-card-explain-label {
    font-size: 12px;
    color: var(--accent);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}
.btn-explain {
    background: var(--bg-input);
    color: var(--accent);
    border: 1px solid var(--border);
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}
.btn-explain:hover { border-color: var(--accent); }
.btn-explain.active {
    background: var(--accent);
    color: var(--bg-primary);
    border-color: var(--accent);
}
.q-card-end {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
    font-size: 15px;
}

/* ── 글자 크게 토글 ── */
.btn-zoom {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
    line-height: 1;
}
.btn-zoom:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.btn-zoom.active {
    background: var(--accent);
    color: var(--bg-primary);
    border-color: var(--accent);
}

/* 줌 적용 시 문제/보기 글자만 2배 (해설/정답 제외) */
body.text-zoom .q-card-question,
body.text-zoom .quiz-btn-text,
body.text-zoom .choice-text,
body.text-zoom .detail-section:first-of-type .content {
    font-size: 2em;
    line-height: 1.5;
}
body.text-zoom .quiz-btn.has-text {
    padding: 10px 14px;
}
body.text-zoom .quiz-btn-letter {
    width: 32px;
    height: 32px;
    line-height: 32px;
    font-size: 15px;
}

/* ── 반응형 ── */
@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
    }
    /* 모바일 필터 바: 한 줄에 맞추되 공간 부족 시 번호 이동 칸은 다음 줄로 */
    .filter-bar {
        flex-wrap: wrap;
        gap: 6px;
    }
    .filter-bar select[name="subject"] {
        flex: 0 1 110px;
        min-width: 0;
        width: auto;
        padding: 8px 6px;
        font-size: 13px;
    }
    .filter-bar input[type="text"] {
        flex: 1 1 0;
        min-width: 0;
        max-width: 50%;
        padding: 8px 10px;
        font-size: 13px;
    }
    .filter-bar input[type="number"] {
        width: 58px;
        padding: 8px 6px;
        font-size: 13px;
    }
    .filter-bar button,
    .filter-bar .btn {
        flex-shrink: 0;
        padding: 6px 10px;
        font-size: 13px;
    }
    .header-inner {
        flex-direction: column;
        gap: 12px;
    }
    /* 모바일 테이블 → 카드 */
    .table-wrap { background: none; box-shadow: none; }
    table, thead, tbody, th, td, tr { display: block; }
    thead { display: none; }
    tbody tr {
        background: var(--bg-card);
        border-radius: var(--radius);
        margin-bottom: 12px;
        padding: 16px;
        box-shadow: var(--shadow);
    }
    tbody td {
        padding: 4px 0;
        border: none;
        display: flex;
        align-items: baseline;
        width: 100% !important;
        max-width: none !important;
        text-align: left;
    }
    tbody td::before {
        content: attr(data-label);
        font-size: 12px;
        color: var(--text-muted);
        font-weight: 500;
        min-width: 60px;
        flex-shrink: 0;
    }
    .truncate { max-width: none; white-space: normal; word-break: break-word; }
    .col-no { display: none; }
    .col-exam-val,
    .col-question,
    .col-quiz,
    .col-review { width: auto !important; text-align: left; }
    .col-question { flex-wrap: wrap; }
    .col-question .truncate {
        flex: 1;
        min-width: 0;
        line-height: 1.5;
    }
    .detail-card { padding: 20px; }
    .detail-header { flex-direction: column; }
}

/* ── 마크다운 렌더링 (문제 내용·해설) ── */
.md-body { white-space: normal; }
.md-body > :first-child { margin-top: 0; }
.md-body > :last-child { margin-bottom: 0; }
.md-p { margin: 0 0 0.7em; }
.md-h { margin: 0.9em 0 0.4em; color: var(--text-primary); line-height: 1.3; }
h1.md-h { font-size: 1.4em; }
h2.md-h { font-size: 1.25em; }
h3.md-h { font-size: 1.12em; }
h4.md-h, h5.md-h, h6.md-h { font-size: 1em; }
.md-ul, .md-ol { margin: 0 0 0.7em; padding-left: 1.6em; }
.md-ul li, .md-ol li { margin: 0.2em 0; }
.md-quote {
    margin: 0 0 0.7em;
    padding: 6px 14px;
    border-left: 3px solid var(--accent);
    background: rgba(255,255,255,0.03);
    color: var(--text-secondary);
}
.md-hr { border: 0; border-top: 1px solid var(--border); margin: 1em 0; }

/* 본문 인라인 이미지 (붙여넣은 캡처) */
.md-img {
    max-width: 100%;
    height: auto;
    margin: 8px 0;
    display: block;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: zoom-in;
}

/* 입력 라벨 보조 안내 */
.label-hint { font-size: 12px; color: var(--text-muted); font-weight: 400; }

/* 인라인 코드 */
.md-code {
    font-family: 'D2Coding', 'Consolas', 'Menlo', 'Courier New', monospace;
    background: rgba(0,210,255,0.13);
    color: #9fe9ff;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.9em;
    word-break: break-all;
}

/* 코드블록 ```lang ... ``` */
.md-pre {
    background: #0b1020;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin: 0 0 0.8em;
    overflow: hidden;
}
.md-pre[data-lang]::before {
    content: attr(data-lang);
    display: block;
    font-family: -apple-system, 'Segoe UI', sans-serif;
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-secondary);
    padding: 4px 14px;
    border-bottom: 1px solid var(--border);
    text-transform: lowercase;
    letter-spacing: 0.5px;
}
.md-pre code {
    display: block;
    font-family: 'D2Coding', 'Consolas', 'Menlo', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.55;
    color: #e6e6e6;
    padding: 14px 16px;
    white-space: pre;
    overflow-x: auto;
    background: none;
    word-break: normal;
}
