/* 구절 암송 연습 — 모바일 우선 (최대 480px) 스타일 */

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
    background: #f4f6fb;
    color: #1a2032;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

.practice-layout {
    max-width: 720px;
    margin: 0 auto;
    padding: 16px 14px 96px;
}

/* ===== 헤더 ===== */
.practice-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 8px;
    padding: 8px 4px 14px;
}

.header-left {
    display: flex;
    align-items: center;
    justify-self: start;
}

.header-right {
    display: flex;
    gap: 8px;
    justify-self: end;
}

.back-link {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 0 8px;
    color: #4a5572;
    text-decoration: none;
    font-size: 14px;
    border-radius: 6px;
}

.back-link:hover {
    background: rgba(74, 85, 114, 0.08);
}

.practice-page-title {
    margin: 0;
    font-size: 18px;
    text-align: center;
    color: #1a2032;
}

.header-btn {
    min-height: 36px;
    padding: 0 10px;
    border: 1px solid #d0d6e3;
    background: #fff;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    color: #2c3754;
    transition: background-color 120ms, border-color 120ms;
}

.header-btn:hover {
    background: #f0f3f9;
}

/* ===== 패널 공용 ===== */
.practice-panel {
    background: #fff;
    border-radius: 14px;
    padding: 20px 18px;
    box-shadow: 0 1px 3px rgba(20, 30, 60, 0.06);
    margin-bottom: 16px;
}

.panel-title {
    margin: 0 0 6px;
    font-size: 17px;
    color: #1a2032;
}

.panel-desc {
    margin: 0 0 16px;
    color: #586278;
    font-size: 14px;
}

.inline-ex {
    background: #eef1f8;
    border-radius: 5px;
    padding: 1px 6px;
    font-size: 0.92em;
    color: #3a4566;
}

/* ===== 생성 폼 ===== */
.practice-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-label {
    font-size: 13px;
    font-weight: 600;
    color: #3b4566;
}

.form-optional {
    font-weight: 400;
    color: #9aa2b8;
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid #d0d6e3;
    border-radius: 9px;
    font-size: 15px;
    font-family: inherit;
    background: #fafbfd;
    color: #1a2032;
    min-height: 44px;
    transition: border-color 120ms, background-color 120ms;
}

.form-textarea {
    resize: vertical;
    min-height: 200px;
    line-height: 1.7;
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: #4a6cf7;
    background: #fff;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.primary-btn {
    flex: 1;
    min-height: 48px;
    padding: 0 16px;
    background: #4a6cf7;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 120ms, transform 80ms;
}

.primary-btn:hover {
    background: #3a5be0;
}

.primary-btn:active {
    transform: translateY(1px);
}

.primary-btn:disabled {
    background: #b6c0d9;
    cursor: not-allowed;
    transform: none;
}

.secondary-btn {
    min-height: 44px;
    padding: 0 18px;
    background: #fff;
    color: #2c3754;
    border: 1px solid #d0d6e3;
    border-radius: 10px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 120ms, border-color 120ms;
}

.secondary-btn:hover {
    background: #f0f3f9;
    border-color: #b6c0d9;
}

.form-hint {
    margin: 0;
    font-size: 12px;
    color: #7a839c;
}

/* ===== 연습 툴바 ===== */
.practice-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.toolbar-right {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.practice-toolbar .secondary-btn {
    padding: 0 14px;
    font-size: 13px;
}

.toggle-btn[aria-pressed="true"] {
    background: #eaf0ff;
    border-color: #9db4f5;
    color: #2f4ec0;
}

/* ===== 학습 방향 선택 ===== */
.mode-selector {
    display: flex;
    gap: 6px;
    margin-bottom: 14px;
}

.mode-btn {
    flex: 1;
    min-height: 44px;
    padding: 4px 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.25;
    background: #fff;
    color: #4a5572;
    border: 1px solid #d0d6e3;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 120ms, border-color 120ms, color 120ms;
}

.mode-btn:hover {
    background: #f0f3f9;
}

.mode-btn[aria-pressed="true"] {
    background: #eaf0ff;
    border-color: #9db4f5;
    color: #2f4ec0;
}

.progress-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 13px;
    color: #4a5572;
}

.progress-text {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.progress-text #practiceSetTitle {
    color: #2c3754;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 60vw;
}

.progress-divider {
    color: #b6c0d9;
}

.known-text {
    flex-shrink: 0;
    color: #2f7a3f;
    font-weight: 600;
}

.progress-bar {
    height: 6px;
    background: #e3e8f2;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 18px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #2f7a3f, #57b86c);
    width: 0%;
    transition: width 220ms ease;
}

/* ===== 플래시카드 ===== */
.flashcard {
    background: #fff;
    border-radius: 16px;
    padding: 28px 20px;
    box-shadow: 0 2px 8px rgba(20, 30, 60, 0.08);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    min-height: 260px;
}

.flashcard-meta {
    align-self: flex-end;
    font-size: 12px;
    color: #7a839c;
}

.flashcard-prompt,
.flashcard-answer {
    width: 100%;
}

/* 참조(짧은 식별자) 표시 — 크고 굵게 */
.is-reference {
    font-size: 24px;
    font-weight: 700;
    color: #1a2032;
    text-align: center;
    word-break: keep-all;
    line-height: 1.5;
}

.flashcard-prompt.is-reference {
    margin-top: 8px;
}

/* 정답으로 노출되는 참조는 살짝 강조 박스 */
.flashcard-answer.is-reference {
    padding: 16px;
    background: #eef5f0;
    border: 1px solid #cfe6d6;
    border-radius: 12px;
}

.reveal-btn {
    min-height: 48px;
    padding: 0 28px;
    background: #4a6cf7;
    color: #fff;
    border: none;
    border-radius: 999px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 120ms, transform 80ms;
    margin-top: 12px;
}

.reveal-btn:hover {
    background: #3a5be0;
}

.reveal-btn:active {
    transform: translateY(1px);
}

/* 본문 표시 — 박스 + 줄바꿈 보존 */
.is-body {
    font-size: 17px;
    line-height: 1.85;
    color: #1a2032;
    white-space: pre-wrap;
    word-break: break-word;
    padding: 16px;
    background: #f7f9fd;
    border-radius: 12px;
    border: 1px solid #e7ecf6;
    text-align: left;
}

.recall-actions {
    display: flex;
    gap: 10px;
    width: 100%;
}

.recall-btn {
    flex: 1;
    min-height: 48px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background-color 120ms, transform 80ms;
}

.recall-btn:active {
    transform: translateY(1px);
}

.recall-btn.again {
    background: #fff;
    color: #b8731f;
    border-color: #eccf9a;
}

.recall-btn.again:hover {
    background: #fdf5e8;
}

.recall-btn.known {
    background: #2f7a3f;
    color: #fff;
}

.recall-btn.known:hover {
    background: #276a35;
}

/* ===== 카드 네비게이션 ===== */
.card-nav {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 16px;
}

.nav-btn {
    flex: 1;
    min-height: 48px;
    padding: 0 16px;
    background: #fff;
    color: #2c3754;
    border: 1px solid #d0d6e3;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 120ms, border-color 120ms;
}

.nav-btn:hover:not(:disabled) {
    background: #f0f3f9;
    border-color: #b6c0d9;
}

.nav-btn:disabled {
    color: #b6c0d9;
    cursor: not-allowed;
    background: #fafbfd;
}

.practice-footer {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

/* ===== 기존 연습 세트 목록 ===== */
.existing-sets-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.existing-set-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
    min-height: 64px;
    padding: 12px 14px;
    background: #fafbfd;
    border: 1px solid #d0d6e3;
    border-radius: 10px;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    color: #1a2032;
    transition: background-color 120ms, border-color 120ms, transform 80ms;
}

.existing-set-card:hover {
    background: #f0f4ff;
    border-color: #b9c5e8;
}

.existing-set-card:active {
    transform: translateY(1px);
}

.existing-set-card:focus-visible {
    outline: 2px solid #4a6cf7;
    outline-offset: 2px;
}

.existing-set-title {
    font-size: 15px;
    font-weight: 600;
    color: #1a2032;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-all;
}

.existing-set-meta {
    font-size: 12px;
    color: #7a839c;
}

/* ===== 안내 상태 ===== */
.state-panel {
    text-align: center;
}

.state-message {
    margin: 12px 0;
    color: #586278;
}

/* ===== 토스트 ===== */
.toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 9000;
    pointer-events: none;
    max-width: calc(100vw - 32px);
}

.toast {
    pointer-events: auto;
    background: #1a2032;
    color: #fff;
    padding: 10px 16px;
    border-radius: 24px;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    animation: toast-in 180ms cubic-bezier(0.2, 0.7, 0.3, 1) both;
    max-width: 90vw;
    text-align: center;
}

.toast.success {
    background: #2f7a3f;
}

.toast.danger {
    background: #b53b3b;
}

.toast.warn {
    background: #b8731f;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== 모달 ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 30, 60, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 9500;
    animation: overlay-in 140ms ease both;
}

@keyframes overlay-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-card {
    background: #fff;
    border-radius: 14px;
    padding: 22px 20px 18px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
    animation: modal-in 180ms cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

@keyframes modal-in {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-title {
    margin: 0 0 12px;
    font-size: 17px;
    color: #1a2032;
}

.modal-body {
    color: #3b4566;
    font-size: 14px;
    margin-bottom: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.modal-btn {
    min-height: 44px;
    padding: 0 16px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background-color 120ms;
}

.modal-cancel {
    background: #fff;
    color: #2c3754;
    border-color: #d0d6e3;
}

.modal-cancel:hover {
    background: #f0f3f9;
}

.modal-ok {
    background: #4a6cf7;
    color: #fff;
}

.modal-ok:hover {
    background: #3a5be0;
}

.modal-ok.danger {
    background: #d95252;
}

.modal-ok.danger:hover {
    background: #b53b3b;
}

/* ===== 모바일 좁은 화면 ===== */
@media (max-width: 480px) {
    .practice-layout {
        padding: 12px 10px 96px;
    }

    .practice-page-title {
        font-size: 16px;
    }

    .practice-panel {
        padding: 16px 14px;
    }

    .flashcard {
        padding: 22px 16px;
    }

    .is-reference {
        font-size: 21px;
    }

    .is-body {
        font-size: 16px;
    }

    .mode-btn {
        font-size: 12px;
        padding: 4px 4px;
    }

    .form-actions {
        flex-direction: column;
    }

    .progress-text #practiceSetTitle {
        max-width: 45vw;
    }

    .recall-actions {
        flex-direction: column;
    }
}
