/* ===== 기본 레이아웃 ===== */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    background: #f5f5f7;
    color: #222;
}

a {
    color: #2563eb;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    background: #111827;
    color: #f9fafb;
    padding: 12px 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.header-inner {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.logo {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: 0.03em;
}

.logo span {
    opacity: 0.7;
    font-weight: 500;
}

.nav-links {
    display: flex;
    gap: 12px;
    font-size: 0.9rem;
}

.nav-links a {
    color: #e5e7eb;
}

.nav-links a:hover {
    color: #ffffff;
}

/* ===== 사용자 메뉴 ===== */
.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
}

.user-name {
    color: #e5e7eb;
    font-weight: 500;
}

.btn-auth {
    padding: 6px 12px;
    border-radius: 6px;
    color: #e5e7eb;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-auth:hover {
    color: #ffffff;
    text-decoration: none;
}

.btn-register {
    background: #2563eb;
    color: #ffffff;
}

.btn-register:hover {
    background: #1d4ed8;
    color: #ffffff;
}

.btn-logout {
    background: #374151;
}

.btn-logout:hover {
    background: #4b5563;
}

/* ===== 인증 폼 ===== */
.auth-form {
    max-width: 400px;
    margin: 40px auto;
}

.auth-form .card {
    padding: 24px;
}

.auth-form h1 {
    text-align: center;
    margin-bottom: 24px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #374151;
}

.form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 1rem;
}

.form-group input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.btn-submit {
    width: 100%;
    padding: 12px;
    background: #2563eb;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-submit:hover {
    background: #1d4ed8;
}

.auth-links {
    text-align: center;
    margin-top: 16px;
    font-size: 0.9rem;
    color: #6b7280;
}

.error-message {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.success-message {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #16a34a;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

main {
    flex: 1;
    padding: 24px 16px 40px;
}

.container {
    max-width: 900px;
    margin: 0 auto;
}

h1 {
    font-size: 1.6rem;
    margin: 0 0 8px;
}

.page-subtitle {
    margin-bottom: 20px;
    font-size: 0.95rem;
    color: #4b5563;
}

/* ===== 카드 / 박스 ===== */
.card {
    background: #ffffff;
    border-radius: 10px;
    padding: 16px 18px;
    box-shadow: 0 8px 20px rgba(15,23,42,0.05);
    margin-bottom: 16px;
}

.verse-card {
    background: #ffffff;
    border-radius: 10px;
    padding: 18px 20px;
    box-shadow: 0 10px 24px rgba(15,23,42,0.08);
    margin-bottom: 18px;
}

.card-title {
    font-weight: 600;
    margin-bottom: 6px;
}

.card-subtitle {
    font-size: 0.9rem;
    color: #6b7280;
    margin-bottom: 10px;
}

.ref-links {
    list-style: disc;
    padding-left: 20px;
    margin-top: 8px;
    margin-bottom: 4px;
    font-size: 0.9rem;
}

.ref-links li {
    margin-bottom: 4px;
}

.ref-links a {
    color: #2563eb;
    text-decoration: none;
}

.ref-links a:hover {
    text-decoration: underline;
}

/* ===== 버튼 ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    font-size: 0.9rem;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: #2563eb;
    color: #ffffff;
    box-shadow: 0 6px 16px rgba(37,99,235,0.35);
}

.btn-primary:hover {
    background: #1d4ed8;
    box-shadow: 0 8px 20px rgba(37,99,235,0.45);
}

.btn-secondary {
    background: #e5e7eb;
    color: #111827;
}

.btn-secondary:hover {
    background: #d1d5db;
}

.btn-danger {
    background: #dc2626;
    color: #ffffff;
    border: none;
    cursor: pointer;
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-ghost {
    background: transparent;
    color: #4b5563;
}

.btn-ghost:hover {
    background: rgba(148,163,184,0.18);
    color: #111827;
}

.btn-sm {
    padding: 6px 10px;
    font-size: 0.8rem;
}

/* ===== 책 목록 / 장 목록 ===== */
.book-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.book-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.book-name {
    font-weight: 500;
}

.book-code {
    font-size: 0.8rem;
    color: #6b7280;
}

.chapter-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chapter-grid .btn {
    min-width: 38px;
}

.nav-bar {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 18px;
}

.nav-bar .btn {
    flex: 1;
    justify-content: center;
}

/* ===== 폼 / 입력 ===== */
textarea {
    width: 100%;
    min-height: 140px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    font-family: inherit;
    font-size: 0.95rem;
    resize: vertical;
}

textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37,99,235,0.15);
}

input[type="text"] {
    width: 100%;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    font-size: 0.95rem;
}

label {
    font-size: 0.85rem;
    color: #4b5563;
    display: block;
    margin-bottom: 4px;
}

.field {
    margin-bottom: 12px;
}

/* ===== 테이블 (통계 등) ===== */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
    font-size: 0.9rem;
    background: #ffffff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 6px 16px rgba(15,23,42,0.05);
}

th, td {
    padding: 8px 10px;
    border-bottom: 1px solid #e5e7eb;
}

th {
    background: #f3f4f6;
    text-align: left;
    font-weight: 600;
    color: #374151;
}

tr:last-child td {
    border-bottom: none;
}

/* ===== 푸터 ===== */
footer {
    padding: 20px 16px 24px;
    font-size: 0.8rem;
    color: #9ca3af;
    text-align: center;
    border-top: 1px solid #e5e7eb;
    margin-top: 20px;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 16px;
    margin-bottom: 10px;
}

.footer-links a {
    color: #6b7280;
    text-decoration: none;
    font-size: 0.85rem;
}

.footer-links a:hover {
    color: #2563eb;
    text-decoration: underline;
}

.footer-copyright {
    font-size: 0.75rem;
    color: #9ca3af;
}

/* ===== About 페이지 ===== */
.about-section {
    margin-bottom: 32px;
}

.about-section h2 {
    font-size: 1.3rem;
    color: #111827;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e5e7eb;
}

.about-section h3 {
    font-size: 1.1rem;
    color: #374151;
    margin: 16px 0 8px;
}

.about-section p {
    line-height: 1.7;
    color: #4b5563;
    margin-bottom: 12px;
}

.about-section ul {
    padding-left: 20px;
    margin-bottom: 12px;
}

.about-section li {
    line-height: 1.6;
    color: #4b5563;
    margin-bottom: 6px;
}

.highlight-box {
    background: #f0f9ff;
    border-left: 4px solid #2563eb;
    padding: 12px 16px;
    margin: 16px 0;
    border-radius: 0 8px 8px 0;
}

.highlight-box p {
    margin: 0;
    color: #1e40af;
}

/* ===== 절 목록 원문 미리보기 ===== */
.original-text-preview {
    font-size: 1.1rem;
    line-height: 1.6;
    color: #374151;
    margin: 8px 0 12px;
    padding: 10px 14px;
    background: #f8fafc;
    border-radius: 6px;
    border-left: 3px solid #2563eb;
}

/* ===== 원문 클릭 분석 패널 ===== */
.original-text-label {
    font-size: 0.9rem;
    color: #6b7280;
    margin-top: 8px;
}

/* 단어별 링크가 포함된 원문 표시 영역 */
.original-text-words {
    font-size: 1.3rem;
    line-height: 2.2;
    color: #1e293b;
    padding: 14px 18px;
    margin: 10px 0;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

/* 히브리어 전용 RTL 클래스 (Safari 호환) */
.original-text-words.rtl-hebrew {
    direction: rtl;
    text-align: right;
}

/* 헬라어 전용 LTR 클래스 */
.original-text-words.ltr-greek {
    direction: ltr;
    text-align: left;
}

/* 개별 단어 링크 기본 스타일 */
.word-link {
    display: inline-block;
    padding: 4px 8px;
    margin: 3px;
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
}

/* 히브리어 단어 링크 */
.word-link-hebrew {
    color: #92400e;
    background: #fef3c7;
    border: 1px solid #fcd34d;
}

.word-link-hebrew:hover {
    background: #fde68a;
    border-color: #f59e0b;
    color: #78350f;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

/* 헬라어 단어 링크 */
.word-link-greek {
    color: #1e40af;
    background: #dbeafe;
    border: 1px solid #93c5fd;
}

.word-link-greek:hover {
    background: #bfdbfe;
    border-color: #3b82f6;
    color: #1e3a8a;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

/* 단어 링크 힌트 텍스트 */
.word-link-hint {
    font-size: 0.8rem;
    color: #6b7280;
    margin: 4px 0 12px;
    font-style: italic;
}

/* ===== 참조 번역 섹션 (개역한글 등) ===== */
.reference-translations-section {
    background: #fefce8;
    border: 1px solid #fde047;
    border-radius: 8px;
    padding: 14px 16px;
    margin-top: 16px;
}

.ref-translation-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 10px;
}

.ref-translation-item:last-child {
    margin-bottom: 0;
}

.ref-version-label {
    background: #ca8a04;
    color: #ffffff;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

.ref-translation-text {
    font-size: 1.05rem;
    line-height: 1.7;
    color: #1c1917;
}

/* 번역 링크 섹션 (KRV, KLB) */
.translation-links {
    background: #f0fdf4;
    border: 1px solid #86efac;
    border-radius: 8px;
    padding: 16px;
    margin-top: 16px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.translation-links .reference-header {
    width: 100%;
    color: #166534;
    border-bottom-color: #86efac;
    margin-bottom: 8px;
}

.btn-translation {
    display: inline-block;
    padding: 10px 18px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-krv {
    background: #2563eb;
    color: #ffffff !important;
    border: 1px solid #1d4ed8;
}

.btn-krv:hover {
    background: #1d4ed8;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
    text-decoration: none;
}

.btn-klb {
    background: #7c3aed;
    color: #ffffff !important;
    border: 1px solid #6d28d9;
}

.btn-klb:hover {
    background: #6d28d9;
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.4);
    text-decoration: none;
}

/* 추가 참고 자료 섹션 */
.reference-section {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 16px;
    margin-top: 16px;
}

.reference-header {
    font-weight: 700;
    color: #1e40af;
    font-size: 1.05rem;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 2px solid #93c5fd;
}

/* 기존 클릭 가능 원문 (유지) */
.original-text-clickable {
    font-size: 1.2rem;
    line-height: 1.8;
    color: #1e293b;
    padding: 12px 16px;
    margin: 8px 0;
    background: #f8fafc;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid #e2e8f0;
}

.original-text-clickable:hover {
    background: #e0f2fe;
    border-color: #2563eb;
}

.click-hint {
    display: block;
    font-size: 0.75rem;
    color: #2563eb;
    margin-top: 6px;
}


.analysis-header {
    font-weight: 600;
    color: #1e40af;
    font-size: 1rem;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #bfdbfe;
}

.analysis-content p {
    color: #1e40af;
    margin-bottom: 12px;
    font-size: 0.9rem;
}

.analysis-link {
    display: inline-block;
    background: #2563eb;
    color: #ffffff !important;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.2s;
}

.analysis-link:hover {
    background: #1d4ed8;
    text-decoration: none;
}

.analysis-note {
    margin-top: 12px;
    font-size: 0.85rem;
    color: #3b82f6;
    padding: 8px 12px;
    background: #dbeafe;
    border-radius: 4px;
}

/* ===== 원어 사전 링크 섹션 ===== */
.lexicon-divider {
    border: none;
    border-top: 1px solid #bfdbfe;
    margin: 16px 0;
}

.lexicon-section {
    margin-top: 8px;
}

.lexicon-header {
    font-weight: 600;
    color: #1e40af;
    font-size: 0.95rem;
    margin-bottom: 6px;
}

.lexicon-desc {
    font-size: 0.85rem;
    color: #3b82f6;
    margin-bottom: 12px;
}

.lexicon-category {
    background: #dbeafe;
    border-radius: 6px;
    padding: 12px 14px;
}

.lexicon-category strong {
    display: block;
    font-size: 0.9rem;
    color: #1e40af;
    margin-bottom: 8px;
}

.lexicon-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.lexicon-list li {
    margin-bottom: 10px;
    padding-left: 0;
}

.lexicon-list li:last-child {
    margin-bottom: 0;
}

.lexicon-list a {
    display: inline-block;
    color: #1d4ed8;
    font-weight: 500;
    text-decoration: none;
    font-size: 0.9rem;
}

.lexicon-list a:hover {
    text-decoration: underline;
    color: #1e40af;
}

.lexicon-note {
    display: block;
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 2px;
    padding-left: 2px;
}

/* ===== 절 페이지 네비게이션 바 ===== */
.verse-nav-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px 24px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.verse-nav-links a {
    color: #3b82f6;
    font-weight: 600;
    font-size: 1rem;
    text-decoration: none;
}

.verse-nav-links a:hover {
    text-decoration: underline;
}

.verse-nav-arrows {
    display: flex;
    gap: 16px;
}

.nav-arrow {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
}

a.nav-arrow {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
}

a.nav-arrow:hover {
    background: #e5e7eb;
    text-decoration: none;
}

span.nav-arrow.disabled {
    background: #f9fafb;
    color: #9ca3af;
    border: 1px solid #e5e7eb;
    cursor: not-allowed;
}

/* ===== 절 네비게이터 ===== */
.verse-navigator {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 32px 36px;
    margin-top: 28px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}

.nav-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: flex-end;
}

.nav-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 160px;
    flex: 1 1 160px;
}

.nav-group label {
    font-size: 1rem;
    font-weight: 700;
    color: #1f2937;
    letter-spacing: -0.01em;
}

.nav-select {
    padding: 14px 18px;
    font-size: 1.05rem;
    border: 2px solid #d1d5db;
    border-radius: 10px;
    background: #fafbfc;
    color: #111827;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    min-height: 52px;
}

.nav-select:hover:not(:disabled) {
    border-color: #9ca3af;
    background: #f3f4f6;
}

.nav-select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
    background: #ffffff;
}

.nav-select:disabled {
    background: #f3f4f6;
    color: #9ca3af;
    cursor: not-allowed;
    border-color: #e5e7eb;
}

.nav-btn-group {
    min-width: auto;
    flex: 0 0 auto;
}

.nav-btn-group .btn {
    padding: 14px 32px;
    font-size: 1.05rem;
    font-weight: 600;
    min-height: 52px;
    border-radius: 10px;
    white-space: nowrap;
}

/* ===== 반응형 ===== */
@media (max-width: 640px) {
    main {
        padding: 18px 10px 30px;
    }

    .card, .verse-card {
        padding: 14px 14px;
    }

    h1 {
        font-size: 1.4rem;
    }
    
    .nav-row {
        flex-direction: column;
        gap: 12px;
    }
    
    .nav-group {
        width: 100%;
    }
    
    .nav-btn-group {
        width: 100%;
    }
    
    .nav-btn-group .btn {
        width: 100%;
    }
    
    .verse-nav-bar {
        flex-direction: column;
        gap: 12px;
        padding: 14px 18px;
    }
    
    .verse-nav-arrows {
        width: 100%;
        justify-content: space-between;
    }
    
    .nav-arrow {
        padding: 8px 16px;
        font-size: 0.9rem;
    }
}
