:root {
    --bg: #f3f5f7;
    --surface: #ffffff;
    --line: #dce2e8;
    --line-strong: #bdc7d1;
    --text: #17212b;
    --muted: #65717d;
    --primary: #2768d7;
    --primary-soft: #eaf1ff;
    --success: #148052;
    --success-soft: #e8f7f0;
    --warning: #a86300;
    --warning-soft: #fff3d9;
    --danger: #bd3c32;
    --shadow: 0 12px 35px rgba(26, 42, 58, .09);
    --radius-lg: 20px;
    --radius-md: 14px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Pretendard", "Noto Sans KR", "맑은 고딕", sans-serif;
    line-height: 1.65;
}
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app-shell { width: min(1180px, calc(100% - 32px)); margin: 20px auto 70px; }
.hero {
    position: relative;
    padding: 36px 72px 30px;
    text-align: center;
    color: #fff;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    background: linear-gradient(135deg, #222a33, #35414d);
    box-shadow: var(--shadow);
}
.home-link {
    position: absolute;
    top: 26px;
    left: 28px;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    color: #fff;
    border: 1px solid rgba(255,255,255,.25);
    border-radius: 12px;
    transition: .2s ease;
}
.home-link:hover { background: rgba(255,255,255,.12); transform: translateY(-1px); }
.eyebrow { margin: 0 0 4px; font-size: 13px; font-weight: 700; letter-spacing: .06em; opacity: .78; }
.hero h1 { margin: 0; font-size: clamp(25px, 4vw, 38px); letter-spacing: -.04em; }
.exam-date { margin: 9px 0 0; font-size: 17px; opacity: .92; }
.exam-date strong { color: #bcd3ff; }

main { background: var(--surface); box-shadow: var(--shadow); }
.control-panel { position: sticky; top: 0; z-index: 20; padding: 22px 28px 14px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.96); backdrop-filter: blur(12px); }
.filter-form { display: grid; grid-template-columns: 1.25fr 1fr 1.55fr 1fr auto; gap: 12px; align-items: end; }
.field { min-width: 0; }
.field > span { display: block; margin: 0 0 6px 3px; color: var(--muted); font-size: 13px; font-weight: 700; }
.field select, .search-box, .primary-button {
    width: 100%; height: 48px; border: 1px solid var(--line-strong); border-radius: 11px; background: #fff;
}
.field select { padding: 0 38px 0 13px; color: var(--text); }
.search-box { display: flex; align-items: center; gap: 8px; padding: 0 12px; }
.search-box svg { flex: 0 0 auto; color: var(--muted); }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; min-width: 0; }
.primary-button { width: 96px; border-color: var(--primary); background: var(--primary); color: #fff; font-weight: 800; }
.primary-button:hover { filter: brightness(.96); }
.quick-tabs { display: flex; gap: 8px; margin-top: 14px; overflow-x: auto; scrollbar-width: thin; }
.quick-tab { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px; padding: 8px 13px; color: var(--muted); text-decoration: none; border: 1px solid var(--line); border-radius: 999px; font-size: 14px; font-weight: 700; }
.quick-tab:hover, .quick-tab.is-active { color: var(--primary); border-color: #aac4f5; background: var(--primary-soft); }
.tab-icon { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

.study-summary { display: grid; grid-template-columns: auto minmax(240px, 1fr) auto; gap: 28px; align-items: center; padding: 25px 30px; background: #f8fafc; border-bottom: 1px solid var(--line); }
.summary-kicker { margin: 0; color: var(--muted); font-size: 13px; }
.study-summary h2 { margin: 0; font-size: 24px; }
.progress-label { display: flex; justify-content: space-between; gap: 15px; margin-bottom: 7px; font-size: 14px; }
.progress-track { height: 9px; overflow: hidden; background: #dfe6ed; border-radius: 99px; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--success); border-radius: inherit; transition: width .25s ease; }
.ghost-button { padding: 9px 13px; border: 1px solid var(--line-strong); border-radius: 10px; background: #fff; color: var(--muted); font-size: 14px; }

.question-list { padding: 30px; }
.question-card { scroll-margin-top: 150px; overflow: hidden; margin-bottom: 28px; border: 1px solid var(--line); border-radius: var(--radius-md); background: #fff; box-shadow: 0 8px 24px rgba(36, 51, 66, .06); }
.question-card.is-complete { border-color: #9bd7bb; box-shadow: 0 8px 24px rgba(20, 128, 82, .08); }
.question-card.is-review { outline: 3px solid rgba(255, 191, 71, .28); }
.question-head { display: flex; justify-content: space-between; gap: 18px; padding: 20px 22px; border-bottom: 1px solid var(--line); background: #fbfcfd; }
.question-position { margin: 0 0 2px; color: var(--muted); font-size: 12px; }
.question-head h3 { margin: 0; font-size: 21px; }
.badges { display: flex; flex-wrap: wrap; justify-content: flex-end; align-content: flex-start; gap: 7px; }
.badge { display: inline-flex; align-items: center; min-height: 27px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.badge-category { color: #44515d; background: #edf1f4; }
.badge-calc { color: var(--primary); background: var(--primary-soft); }
.badge-frequent { color: var(--warning); background: var(--warning-soft); }
.badge-score { color: var(--success); background: var(--success-soft); }
.question-body { padding: 27px 24px 20px; }
.question-type { display: inline-block; margin: 0 0 10px; color: var(--primary); font-size: 13px; font-weight: 800; }
.question-text { margin: 0; font-size: clamp(18px, 2.2vw, 22px); font-weight: 750; letter-spacing: -.02em; }
.question-details { margin: 20px 0 0; padding: 18px 22px 18px 44px; border: 1px dashed var(--line-strong); border-radius: 10px; background: #fcfdfe; }
.question-details li + li { margin-top: 8px; }
.answer-workspace { padding: 0 24px 23px; }
.answer-workspace label { display: block; margin: 0 0 7px; font-weight: 800; }
.user-answer { width: 100%; resize: vertical; min-height: 132px; padding: 14px 15px; border: 1px solid var(--line-strong); border-radius: 10px; outline: 0; line-height: 1.7; }
.user-answer:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(39, 104, 215, .12); }
.autosave-note { margin: 5px 2px 0; color: var(--muted); font-size: 12px; }
.answer-panels { padding: 0 24px; }
.reveal-panel, .explanation-panel { margin-bottom: 18px; padding: 18px 19px; border-radius: 11px; }
.reveal-panel { border-left: 4px solid var(--primary); background: var(--primary-soft); }
.explanation-panel { border-left: 4px solid var(--success); background: var(--success-soft); }
.reveal-panel h4, .explanation-panel h4 { margin: 0 0 7px; }
.question-actions { display: flex; flex-wrap: wrap; gap: 9px; padding: 17px 24px; border-top: 1px solid var(--line); background: #fbfcfd; }
.action-button { padding: 9px 13px; border: 1px solid var(--line-strong); border-radius: 9px; background: #fff; font-weight: 700; }
.action-button:hover { border-color: var(--primary); color: var(--primary); }
.action-button[aria-pressed="true"] { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.mark-complete[aria-pressed="true"] { border-color: var(--success); color: var(--success); background: var(--success-soft); }
.mark-review[aria-pressed="true"] { border-color: #d89a26; color: #936006; background: var(--warning-soft); }
.empty-state { display: grid; gap: 4px; place-items: center; min-height: 230px; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--radius-md); }
.empty-state strong { color: var(--text); font-size: 19px; }
.page-footer { padding: 25px; text-align: center; color: var(--muted); font-size: 14px; }
.page-footer p { margin: 2px 0; }
.mobile-toolbar { display: none; }

@media (max-width: 950px) {
    .filter-form { grid-template-columns: 1fr 1fr; }
    .field-search { grid-column: 1 / -1; }
    .primary-button { width: 100%; }
    .study-summary { grid-template-columns: 1fr; gap: 15px; }
    .ghost-button { justify-self: start; }
}

@media (max-width: 650px) {
    .app-shell { width: 100%; margin: 0 0 72px; }
    .hero { border-radius: 0; padding: 28px 48px 24px; }
    .home-link { left: 14px; top: 18px; width: 38px; height: 38px; }
    .eyebrow { display: none; }
    .hero h1 { font-size: 24px; }
    .exam-date { font-size: 15px; }
    .control-panel { padding: 15px 14px 10px; }
    .filter-form { grid-template-columns: 1fr; gap: 9px; }
    .field-search { grid-column: auto; }
    .field > span { display: none; }
    .study-summary, .question-list { padding: 18px 14px; }
    .study-summary { grid-template-columns: 1fr; }
    .question-head { display: block; padding: 17px; }
    .badges { justify-content: flex-start; margin-top: 11px; }
    .question-body { padding: 21px 17px 17px; }
    .answer-workspace, .answer-panels { padding-left: 17px; padding-right: 17px; }
    .question-details { padding-left: 38px; }
    .question-actions { padding: 14px 17px; }
    .action-button { flex: 1 1 calc(50% - 9px); }
    .mobile-toolbar { position: fixed; z-index: 50; bottom: 0; left: 0; right: 0; display: grid; grid-template-columns: repeat(3, 1fr); padding: 8px max(10px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); border-top: 1px solid var(--line); background: rgba(255,255,255,.96); backdrop-filter: blur(12px); }
    .mobile-toolbar button { min-height: 46px; border: 0; background: transparent; font-weight: 800; }
}

/* ============================================================
   음성 학습
   ============================================================ */
.study-summary-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
}
.voice-study-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}
.voice-study-controls .ghost-button {
    white-space: nowrap;
}
.voice-stop {
    color: var(--danger);
}
.question-card.is-speaking {
    border-color: #7fa8ed;
    box-shadow: 0 0 0 3px rgba(39, 104, 215, .10), 0 8px 24px rgba(36, 51, 66, .06);
}
.voice-question,
.voice-full,
.voice-full-detail,
.voice-answer {
    border-color: #aac4f5;
    color: var(--primary);
}
.voice-question:hover,
.voice-full:hover,
.voice-full-detail:hover,
.voice-answer:hover {
    background: var(--primary-soft);
}
button:disabled {
    opacity: .45;
    cursor: not-allowed;
}

@media (max-width: 950px) {
    .study-summary-actions {
        align-items: flex-start;
    }
}

@media (max-width: 650px) {
    .voice-study-controls {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
    .voice-study-controls .voice-stop {
        grid-column: 1 / -1;
    }
    .study-summary-actions {
        width: 100%;
    }
}



/* 모바일 음성 안정화 패치 */
.voice-stop {
    font-weight: 800;
}
.voice-stop:not(:disabled) {
    border-color: #e0a0a0;
}
@media (max-width: 650px) {
    .voice-study-controls .ghost-button,
    .question-actions .voice-question,
    .question-actions .voice-full,
    .question-actions .voice-full-detail,
    .question-actions .voice-answer {
        min-height: 44px;
    }
}


/* 개별 문제 음성 정지 버튼 */
.voice-card-stop {
    color: var(--danger);
    border-color: #e0b0b0;
    font-weight: 800;
}
.voice-card-stop:hover {
    color: var(--danger);
    border-color: #d78686;
    background: #fff5f5;
}

/* ============================================================
   모바일: 상단 검색/필터 영역이 화면을 과도하게 차지하지 않도록 축소
   ============================================================ */
@media (max-width: 650px) {
    /* 모바일에서는 상단 필터를 고정(sticky)하지 않음 */
    .control-panel {
        position: static;
        top: auto;
        z-index: auto;
        padding: 10px 12px 8px;
    }

    /* 4개 입력을 2열로 압축 */
    .filter-form {
        grid-template-columns: 1fr 1fr;
        gap: 7px;
    }

    .field-search {
        grid-column: 1 / -1;
    }

    /* 검색창은 한 줄 전체, 높이는 축소 */
    .field select,
    .search-box,
    .primary-button {
        height: 40px;
        min-height: 40px;
        border-radius: 9px;
        font-size: 14px;
    }

    .field select {
        padding-left: 10px;
        padding-right: 28px;
    }

    .search-box {
        padding: 0 10px;
    }

    /* 선택 버튼은 한 줄 전체 */
    .primary-button {
        grid-column: 1 / -1;
        width: 100%;
        height: 42px;
    }

    /* 빠른 탭도 조금 더 작게 */
    .quick-tabs {
        gap: 6px;
        margin-top: 9px;
        padding-bottom: 2px;
    }

    .quick-tab {
        padding: 6px 10px;
        font-size: 13px;
    }

    /* 요약 영역도 세로 공간 축소 */
    .study-summary {
        padding: 12px 14px;
        gap: 10px;
    }

    .study-summary h2 {
        font-size: 20px;
    }

    .progress-label {
        margin-bottom: 5px;
    }

    /* 음성 버튼도 너무 큰 높이를 차지하지 않게 */
    .voice-study-controls {
        gap: 6px;
    }

    .voice-study-controls .ghost-button {
        min-height: 40px;
        padding: 7px 9px;
        font-size: 13px;
    }

}

/* ============================================================
   전체 화면: 상단 필터 영역 고정 해제
   ============================================================ */
.control-panel {
    position: static;
    top: auto;
    z-index: auto;
}



/* 문제번호 영역의 음성 버튼 */
.question-title-wrap { min-width: 0; }
.question-title-line {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 14px;
}
.question-title-line h3 { margin: 0; }
.question-voice-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}
.question-voice-controls .action-button {
    min-height: 34px;
    padding: 6px 9px;
    font-size: 12px;
    white-space: nowrap;
}

@media (max-width: 650px) {
    .question-title-line { display: block; }
    .question-voice-controls {
        width: 100%;
        margin-top: 10px;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
    }
    .question-voice-controls .action-button {
        width: 100%;
        min-height: 40px;
        padding: 7px 5px;
        font-size: 12px;
    }
}


/* ============================================================
   내 답안: 필요할 때만 펼치는 보조 기능
   ============================================================ */
.my-answer-toggle-wrap {
    padding: 0 24px 16px;
}

.my-answer-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 7px 12px;
    border: 1px dashed var(--line-strong);
    border-radius: 9px;
    background: #fff;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.my-answer-toggle:hover {
    color: var(--primary);
    border-color: #aac4f5;
    background: var(--primary-soft);
}

.answer-workspace[hidden] {
    display: none !important;
}

@media (max-width: 650px) {
    .my-answer-toggle-wrap {
        padding: 0 17px 14px;
    }

    .my-answer-toggle {
        width: 100%;
        min-height: 40px;
    }
}


/* ============================================================
   음성 연속듣기 시작점 / 재생속도
   ============================================================ */
.voice-rate-control {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 4px 7px 4px 10px;
    border: 1px solid var(--line-strong);
    border-radius: 9px;
    background: #fff;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.voice-rate-control select {
    height: 28px;
    padding: 0 24px 0 8px;
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    background: #fff;
    color: var(--text);
    font-weight: 800;
}

.voice-card-continuous {
    color: var(--primary);
    border-color: #aac4f5;
}

.voice-card-continuous:hover {
    background: var(--primary-soft);
}

@media (max-width: 650px) {
    .voice-rate-control {
        min-height: 40px;
        justify-content: center;
    }

    /* 문제별 음성 버튼이 5개이므로 마지막 정지는 한 줄 전체 */
    .question-voice-controls .voice-card-stop {
        grid-column: 1 / -1;
    }
}


/* ============================================================
   v15: 문제헤더 정보/음성 UI 정리
   ============================================================ */
.badge-type {
    color: var(--primary);
    background: var(--primary-soft);
}

@media (max-width: 650px) {
    /* 문제번호 아래 음성메뉴를 한 줄에 압축 */
    .question-voice-controls {
        display: flex !important;
        flex-wrap: nowrap !important;
        width: 100%;
        gap: 4px;
        overflow-x: auto;
        padding-bottom: 2px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .question-voice-controls::-webkit-scrollbar {
        display: none;
    }

    .question-voice-controls .action-button {
        flex: 1 0 auto;
        width: auto !important;
        min-width: 0;
        min-height: 36px;
        padding: 6px 8px;
        font-size: 11px;
        white-space: nowrap;
    }

    .question-voice-controls .voice-card-stop {
        grid-column: auto !important;
    }

    /* 서술형/미분류/5점 등을 같은 줄에 모음 */
    .badges {
        width: 100%;
        justify-content: flex-start;
        margin-top: 10px;
    }
}

@media (max-width: 650px) {
    .question-voice-controls {
        overflow-x: visible;
        gap: 3px;
    }
    .question-voice-controls .action-button {
        flex: 1 1 0;
        min-width: 0;
        padding: 6px 3px;
        font-size: 10.5px;
        letter-spacing: -0.4px;
    }
    .question-voice-controls .voice-card-continuous { flex: 1.12 1 0; }
    .question-voice-controls .voice-card-stop { flex: 0.78 1 0; }
}


/* ============================================================
   2026-08-19 학습 요약 축소 / 전체 답안 / 문제 관리
   ============================================================ */
.study-summary {
    grid-template-columns: auto minmax(180px, .7fr) auto;
    gap: 16px;
    padding: 14px 22px;
}
.study-count { min-width: 92px; }
.study-summary h2 { font-size: 19px; line-height: 1.25; }
.summary-kicker { font-size: 11px; }
.progress-label { margin-bottom: 4px; font-size: 12px; }
.progress-track { height: 7px; }
.study-summary-actions { gap: 6px; }
.answer-all-controls { display: flex; gap: 6px; }
.answer-all-controls .ghost-button,
.reset-progress-button {
    min-height: 34px;
    padding: 6px 10px;
    font-size: 12px;
}
#openAllAnswers { color: var(--primary); }
#closeAllAnswers { color: var(--danger); }

.question-head-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 9px;
}
.question-manage-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 5px 11px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: #fff;
    color: var(--muted);
    text-decoration: none;
    font-size: 12px;
    font-weight: 800;
}
.question-manage-button:hover {
    color: var(--primary);
    border-color: #aac4f5;
    background: var(--primary-soft);
}

@media (max-width: 900px) {
    .study-summary {
        grid-template-columns: 1fr;
        gap: 9px;
        padding: 10px 14px;
    }
    .study-count { display: flex; align-items: baseline; gap: 7px; }
    .study-summary h2 { font-size: 17px; }
    .study-summary-actions { width: 100%; }
    .answer-all-controls { width: 100%; }
    .answer-all-controls .ghost-button { flex: 1 1 0; }
    .reset-progress-button { align-self: flex-start; }
    .question-head-side {
        margin-top: 10px;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
    .question-head-side .badges { margin-top: 0; }
    .question-manage-button { flex: 0 0 auto; }
}

/* ============================================================
   2026-08-19 답안 조작 중심 UI 보강
   ============================================================ */
.study-count {
    min-width: auto;
    align-self: center;
}
.study-count span {
    display: inline-block;
    padding: 3px 7px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.answer-all-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.answer-all-controls .ghost-button {
    min-height: 36px;
    padding: 6px 11px;
    font-size: 12px;
    font-weight: 800;
}
#openAllAnswers { color: var(--primary); border-color: #a9c5f5; background: #f6f9ff; }
#openAllAnswersAndDetails { color: var(--success); border-color: #acd9c6; background: #f5fbf8; }
#closeAllAnswers { color: var(--danger); border-color: #e6b4af; background: #fff8f7; }

.question-manage-button {
    gap: 4px;
    min-height: 34px;
    padding: 6px 12px;
    border: 1px solid #9fbcf0;
    border-radius: 9px;
    background: #f4f8ff;
    color: #2464cc;
    box-shadow: 0 1px 2px rgba(37, 99, 235, .08);
    font-size: 12px;
    font-weight: 800;
}
.question-manage-button span {
    font-size: 13px;
    line-height: 1;
}
.question-manage-button:hover,
.question-manage-button:focus-visible {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary);
    outline: none;
}

@media (max-width: 900px) {
    .study-summary {
        grid-template-columns: auto 1fr;
        gap: 7px 10px;
        padding: 9px 14px 11px;
    }
    .study-count {
        grid-column: 1;
        grid-row: 1;
        display: block;
    }
    .progress-wrap {
        grid-column: 2;
        grid-row: 1;
        min-width: 0;
    }
    .study-summary-actions {
        grid-column: 1 / -1;
        grid-row: 2;
    }
    .answer-all-controls {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    .answer-all-controls .ghost-button {
        width: 100%;
        min-width: 0;
        padding-left: 5px;
        padding-right: 5px;
        font-size: 11px;
        white-space: nowrap;
    }
}

@media (max-width: 520px) {
    .answer-all-controls {
        grid-template-columns: 1fr 1.22fr 1fr;
        gap: 5px;
    }
    .question-manage-button {
        min-height: 32px;
        padding: 5px 10px;
        font-size: 11px;
    }
}


/* ============================================================
   2026-08-20 진행률 최소화 / 조작 버튼 우선
   ============================================================ */
.study-summary {
    display: grid;
    grid-template-columns: 132px minmax(0, 1fr);
    gap: 10px 16px;
    align-items: center;
    padding: 10px 18px 12px;
}

.study-progress-mini {
    width: 132px;
    min-width: 0;
}
.study-progress-mini-title {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    line-height: 1.2;
}
.study-progress-mini-text {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 10.5px;
    line-height: 1.2;
    white-space: nowrap;
}
.study-progress-mini-text span {
    font-weight: 700;
}
.study-progress-mini-text strong {
    color: var(--text);
    font-size: 11px;
    font-weight: 800;
}
.study-progress-mini .progress-track {
    width: 100%;
    height: 4px;
    margin: 0;
}

.study-summary-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 7px;
    min-width: 0;
}
.study-summary-actions .voice-study-controls {
    flex: 0 1 auto;
}
.study-summary-actions .answer-all-controls {
    flex: 1 1 420px;
    min-width: 0;
}

/* 기존의 큰 진행률 관련 요소는 이 버전에서 사용하지 않음 */
.study-summary .study-count,
.study-summary .progress-wrap,
.study-summary .progress-label {
    display: none !important;
}

@media (max-width: 900px) {
    .study-summary {
        grid-template-columns: 1fr;
        gap: 7px;
        padding: 8px 12px 10px;
    }
    .study-progress-mini {
        width: 118px;
        justify-self: start;
    }
    .study-progress-mini-text {
        font-size: 10px;
        margin-bottom: 3px;
    }
    .study-progress-mini-text strong {
        font-size: 10.5px;
    }
    .study-progress-mini .progress-track {
        height: 3px;
    }
    .study-summary-actions {
        width: 100%;
        gap: 6px;
    }
    .study-summary-actions .voice-study-controls,
    .study-summary-actions .answer-all-controls {
        width: 100%;
        flex-basis: 100%;
    }
}

@media (max-width: 520px) {
    .study-summary {
        padding-top: 7px;
    }
    .study-progress-mini {
        width: 105px;
    }
    .study-progress-mini-text span {
        display: none;
    }
    .study-progress-mini-text {
        justify-content: flex-start;
        margin-bottom: 2px;
    }
}


/* 2026-08-20 관리 버튼을 정보 배지 줄에 통합 */
.question-head-side {
    display: block;
}
.question-manage-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 27px;
    padding: 3px 9px;
    border: 1px solid #b9c9df;
    border-radius: 999px;
    background: #f4f7fb;
    color: #40556e;
    box-shadow: none;
    text-decoration: none;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.2;
}
.question-manage-button span {
    font-size: 11px;
    line-height: 1;
}
.question-manage-button:hover,
.question-manage-button:focus-visible {
    border-color: #8eabd1;
    background: #eaf1fb;
    color: #245b9e;
    outline: none;
}
@media (max-width: 900px) {
    .question-head-side { margin-top: 10px; }
    .question-head-side .badges {
        margin-top: 0;
        justify-content: flex-start;
    }
}
@media (max-width: 520px) {
    .question-manage-button {
        min-height: 27px;
        padding: 3px 9px;
        font-size: 12px;
    }
}

/* ============================================================
   2026-08-20 v5 - 조작 중심 레이아웃 / 버튼 크기 정상화
   ============================================================ */

/* 상단 학습 조작 영역: 진행률은 작게, 조작 버튼은 크게 */
.study-summary {
    display: grid !important;
    grid-template-columns: 150px minmax(0, 1fr) !important;
    grid-template-rows: auto auto !important;
    column-gap: 22px !important;
    row-gap: 10px !important;
    align-items: center !important;
    padding: 16px 18px !important;
    background: #f8fafc;
}

.study-progress-mini {
    grid-column: 1 !important;
    grid-row: 1 / span 2 !important;
    width: 150px !important;
    align-self: center !important;
}

.study-progress-mini-text {
    margin-bottom: 7px !important;
    font-size: 11px !important;
}

.study-progress-mini-text strong {
    font-size: 12px !important;
}

.study-progress-mini .progress-track {
    height: 5px !important;
}

/* 중간 래퍼가 grid 배치를 방해하지 않도록 해제 */
.study-summary-actions {
    display: contents !important;
}

.answer-all-controls {
    grid-column: 2 !important;
    grid-row: 1 !important;
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 10px !important;
    width: 100% !important;
    min-width: 0 !important;
}

.answer-all-controls .ghost-button {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 56px !important;
    height: 56px !important;
    padding: 0 14px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 12px !important;
    font-size: 14px !important;
    font-weight: 800 !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04) !important;
}

#openAllAnswers {
    color: #1764d8 !important;
    border-color: #82adf5 !important;
    background: #f7faff !important;
}
#openAllAnswersAndDetails {
    color: #15804f !important;
    border-color: #8fd0b1 !important;
    background: #f5fbf8 !important;
}
#closeAllAnswers {
    color: #d13c31 !important;
    border-color: #eda59e !important;
    background: #fff8f7 !important;
}

#openAllAnswers:hover { background: #edf4ff !important; border-color: #4d8fea !important; }
#openAllAnswersAndDetails:hover { background: #ebf8f1 !important; border-color: #58b989 !important; }
#closeAllAnswers:hover { background: #fff0ee !important; border-color: #df746a !important; }

.voice-study-controls {
    grid-column: 2 !important;
    grid-row: 2 !important;
    display: flex !important;
    align-items: center !important;
    flex-wrap: wrap !important;
    gap: 7px !important;
    width: 100% !important;
}

.voice-study-controls .ghost-button {
    width: auto !important;
    min-width: 0 !important;
    min-height: 42px !important;
    height: 42px !important;
    padding: 0 13px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 10px !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    white-space: nowrap !important;
}

.voice-rate-control {
    min-height: 42px !important;
    height: 42px !important;
    padding: 0 7px 0 10px !important;
    border-radius: 10px !important;
}
.voice-rate-control select {
    min-height: 32px !important;
    height: 32px !important;
}

/* 문제 카드 헤더 */
.question-head {
    align-items: flex-start !important;
}

.question-head-side .badges {
    align-items: center !important;
}

/* 관리 버튼은 배지와 정확히 같은 체급 */
.question-manage-button {
    min-height: 27px !important;
    height: 27px !important;
    padding: 3px 9px !important;
    border-radius: 999px !important;
    border: 1px solid #a9c2e8 !important;
    background: #f5f8fd !important;
    color: #315d98 !important;
    font-size: 12px !important;
    font-weight: 800 !important;
    line-height: 1 !important;
    box-shadow: none !important;
    vertical-align: middle !important;
}
.question-manage-button span {
    font-size: 11px !important;
}

/* 문제별 핵심 조작 버튼 */
.question-actions {
    gap: 10px !important;
    padding: 14px 22px !important;
    align-items: center !important;
}

.question-actions .action-button {
    flex: 0 0 auto !important;
    min-height: 44px !important;
    height: 44px !important;
    padding: 0 16px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 10px !important;
    font-size: 13px !important;
    font-weight: 800 !important;
    white-space: nowrap !important;
}

.question-actions .reveal-answer {
    color: #1764d8 !important;
    border-color: #82adf5 !important;
    background: #f7faff !important;
}
.question-actions .reveal-explanation {
    color: #15804f !important;
    border-color: #8fd0b1 !important;
    background: #f5fbf8 !important;
}
.question-actions .mark-review {
    color: #9a6300 !important;
    border-color: #e2bd74 !important;
    background: #fffaf0 !important;
}
.question-actions .mark-complete {
    color: #15804f !important;
    border-color: #9bcfb6 !important;
    background: #f6fbf8 !important;
}

.question-actions .reveal-answer:hover { background: #edf4ff !important; }
.question-actions .reveal-explanation:hover { background: #ebf8f1 !important; }
.question-actions .mark-review:hover { background: #fff5df !important; }
.question-actions .mark-complete:hover { background: #ecf8f1 !important; }

/* 태블릿 / 모바일 */
@media (max-width: 900px) {
    .study-summary {
        grid-template-columns: 110px minmax(0, 1fr) !important;
        column-gap: 12px !important;
        padding: 12px !important;
    }
    .study-progress-mini {
        width: 110px !important;
    }
    .answer-all-controls {
        gap: 7px !important;
    }
    .answer-all-controls .ghost-button {
        min-height: 48px !important;
        height: 48px !important;
        padding: 0 8px !important;
        font-size: 12px !important;
    }
    .voice-study-controls .ghost-button {
        min-height: 40px !important;
        height: 40px !important;
        font-size: 12px !important;
    }
    .question-actions .action-button {
        flex: 1 1 calc(50% - 5px) !important;
    }
}

@media (max-width: 650px) {
    .study-summary {
        grid-template-columns: 1fr !important;
        grid-template-rows: auto auto auto !important;
        row-gap: 8px !important;
        padding: 10px 12px 12px !important;
    }
    .study-progress-mini {
        grid-column: 1 !important;
        grid-row: 1 !important;
        width: 90px !important;
    }
    .study-progress-mini-text {
        margin-bottom: 3px !important;
    }
    .study-progress-mini-text span {
        display: none !important;
    }
    .answer-all-controls {
        grid-column: 1 !important;
        grid-row: 2 !important;
        grid-template-columns: 1fr 1.18fr 1fr !important;
        gap: 5px !important;
    }
    .answer-all-controls .ghost-button {
        min-height: 43px !important;
        height: 43px !important;
        padding: 0 5px !important;
        font-size: 11px !important;
        border-radius: 9px !important;
    }
    .voice-study-controls {
        grid-column: 1 !important;
        grid-row: 3 !important;
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        gap: 5px !important;
        scrollbar-width: none;
    }
    .voice-study-controls::-webkit-scrollbar { display: none; }
    .voice-study-controls .ghost-button {
        flex: 0 0 auto !important;
        min-height: 39px !important;
        height: 39px !important;
        padding: 0 10px !important;
        font-size: 11px !important;
    }
    .voice-rate-control {
        flex: 0 0 auto !important;
        min-height: 39px !important;
        height: 39px !important;
    }
    .question-head {
        padding: 15px 14px !important;
    }
    .question-head-side {
        margin-top: 9px !important;
    }
    .question-head-side .badges {
        gap: 5px !important;
    }
    .question-manage-button {
        min-height: 27px !important;
        height: 27px !important;
        padding: 3px 8px !important;
        font-size: 11px !important;
    }
    .question-actions {
        display: grid !important;
        grid-template-columns: 1.05fr 1.25fr 1fr 1fr !important;
        gap: 6px !important;
        padding: 11px 12px !important;
    }
    .question-actions .action-button {
        width: 100% !important;
        min-width: 0 !important;
        min-height: 42px !important;
        height: 42px !important;
        padding: 0 5px !important;
        font-size: 11px !important;
        flex: none !important;
    }
}

@media (max-width: 420px) {
    .answer-all-controls .ghost-button {
        font-size: 10.5px !important;
    }
    .question-actions {
        grid-template-columns: 1fr 1.2fr !important;
    }
}

/* ============================================================
   2026-08-20 v7 - 답안 전체 조작 버튼 컴팩트화
   ============================================================ */
@media (min-width: 761px) {
    .answer-all-controls {
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 8px !important;
        width: 100% !important;
    }

    .answer-all-controls .ghost-button {
        width: auto !important;
        min-width: 148px !important;
        min-height: 40px !important;
        height: 40px !important;
        padding: 0 16px !important;
        border-radius: 10px !important;
        font-size: 12px !important;
        font-weight: 800 !important;
    }

    #openAllAnswersAndDetails {
        min-width: 176px !important;
    }
}

@media (max-width: 760px) {
    .answer-all-controls .ghost-button {
        min-height: 40px !important;
        height: 40px !important;
        padding-left: 7px !important;
        padding-right: 7px !important;
        border-radius: 9px !important;
        font-size: 11px !important;
    }
}

/* ============================================================
   2026-08-20 v8 - 상단 조작 영역 중심축 정렬
   ============================================================ */
@media (min-width: 901px) {
    .study-summary {
        grid-template-columns: 150px minmax(0, 1fr) !important;
        column-gap: 22px !important;
        row-gap: 10px !important;
    }

    .answer-all-controls {
        width: auto !important;
        justify-self: center !important;
        justify-content: center !important;
    }

    .voice-study-controls {
        width: auto !important;
        justify-self: center !important;
        justify-content: center !important;
    }
}

@media (min-width: 761px) and (max-width: 900px) {
    .answer-all-controls,
    .voice-study-controls {
        width: auto !important;
        justify-self: center !important;
        justify-content: center !important;
    }
}
