/* 고전 상세 상단 바 — 마켓플레이스(public/pages/marketplace/marketplace.css)의
   토큰 규격을 그대로 들여온다. 사이트 헤더(assets/components/header.css)가
   유리질 배경 + 1px 헤어라인이라, 그 아래에 굵은 선을 또 그으면 위계가 깨진다. */
.content-title.sticky {
    --cd-surface: #ffffff;
    --cd-surface-2: #f3f4f6;
    --cd-border: #e6e7ea;
    --cd-border-2: #d3d5da;
    --cd-text: #1f2328;
    --cd-text-muted: #565b62;
    --cd-text-soft: #8a8f96;
    --cd-link: var(--color-primary);

    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    padding: 14px 20px 12px;
    margin: -20px -20px 15px;
    background: rgba(255, 255, 255, 0.78);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(193, 210, 233, 0.6);
    box-shadow: none;
    transition: padding 0.18s ease, box-shadow 0.18s ease;
}

.content-title.sticky.scrolled {
    padding: 9px 20px;
    box-shadow: 0 10px 24px -20px rgba(31, 35, 40, 0.55);
}

.classic-title-top {
    width: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
}

.classic-title-left {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 7px;
    min-width: 0;
}

/* 위치 표시 — 현재 권은 아래 제목이 맡으므로 크럼에서 뺀다 */
.cd-breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin: 0;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--cd-text-soft);
}

.cd-breadcrumb a {
    color: var(--cd-link);
    text-decoration: none;
}

/* 호버 신호는 색으로만 낸다 — 밑줄은 긋지 않는다.
   앱의 다른 breadcrumb 는 밑줄을 안 긋고(병원 워크스페이스는 text-decoration:none 을 명시),
   고전 셋(.cd-·.cs-·.cv-)만 서로 베껴 가며 밑줄을 달고 있었다. 새 breadcrumb 를 만들 때
   옆엣것을 통째로 옮기지 말 것. 다크는 theme.dark.css 의 전역 `a:hover` 가 이미
   #c2c8d0 → #edf0f3 로 밝히므로 여기 색은 라이트에만 걸린다. */
.cd-breadcrumb a:hover {
    color: #2f4d76;
}

.cd-breadcrumb i {
    font-size: 0.62rem;
    opacity: 0.55;
}

.cd-title-block {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
    min-width: 0;
}

/* .classic-content h2 의 파란 밑줄을 여기서 끊는다 */
.content-title.sticky h2.cd-title {
    flex: 0 0 auto;
    min-width: 0;
    margin: 0;
    padding-bottom: 0;
    border-bottom: none;
    font-size: 1.34rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--cd-text);
}

/* 저자·연도에 라벨을 단다 — 값이 '미상'인 책이 많아(저자 150건)
   라벨이 없으면 무엇이 미상인지 읽히지 않는다 */
.cd-meta {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin: 0;
}

.cd-meta b {
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--cd-text-soft);
}

.cd-meta em {
    font-style: normal;
    font-size: 0.78rem;
    color: var(--cd-text-muted);
}

.cd-meta-sep {
    width: 1px;
    height: 9px;
    margin: 0 4px;
    background: var(--cd-border-2);
}

/* 스크롤 중에는 제목과 권 선택만 남긴다 */
.content-title.sticky.scrolled .cd-breadcrumb,
.content-title.sticky.scrolled .cd-meta {
    display: none;
}

.content-title.sticky.scrolled h2.cd-title {
    font-size: 1.1rem;
}

/* 오른쪽 컨트롤 묶음 — 수정모드 스위치와 권 선택 */
.cd-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-left: auto;
}

.cd-actions .edit-mode-switch {
    padding-right: 14px;
    border-right: 1px solid var(--cd-border);
}

.cd-actions .edit-mode-switch-text {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--cd-text-soft);
}

.cd-actions .edit-mode-switch input:checked ~ .edit-mode-switch-text {
    color: var(--cd-text);
}

.volume-select-slot {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

/* 권 값이 숫자가 아니라 편 제목인 책이 있어서 卷 은 라벨로 앞에 세운다 */
.cd-vol-label {
    flex-shrink: 0;
    font-size: 0.82rem;
    color: var(--cd-text-muted);
}

.volume-select {
    max-width: 260px;
    padding: 0.5rem 2rem 0.5rem 0.8rem;
    border: 1px solid var(--cd-border);
    border-radius: 10px;
    background-color: var(--cd-surface);
    color: var(--cd-text);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    box-shadow: none;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238a8f96' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 11px center;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.volume-select:hover {
    border-color: var(--cd-border-2);
    background-color: var(--cd-surface-2);
    box-shadow: none;
}

.volume-select:focus {
    outline: none;
    border-color: var(--cd-border-2);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 14%, transparent);
}

.volume-select option {
    font-weight: normal;
}

/* 수정모드 도구 — 제목 줄과 헤어라인으로 가른다 */
#hierarchyControls {
    width: 100%;
    margin-top: 11px;
    padding-top: 11px;
    border-top: 1px solid var(--cd-border);
}

.content-title.sticky .hierarchy-action-buttons button {
    min-width: 0;
    padding: 0.45rem 0.85rem;
    border: 1px solid var(--cd-border);
    border-radius: 9px;
    background: var(--cd-surface-2);
    color: var(--cd-text);
    font-size: 0.82rem;
    font-weight: 600;
    box-shadow: none;
}

.content-title.sticky .hierarchy-action-buttons button:hover {
    border-color: var(--cd-border-2);
    box-shadow: none;
}

.content-title.sticky .hierarchy-action-buttons .save-btn {
    background-color: #e9f6f1 !important;
    color: #2d7a5f !important;
    border-color: #c6e5d9;
}

.content-title.sticky .hierarchy-action-buttons .save-btn:hover {
    background-color: #ddf0e7 !important;
}

/* 인용 버튼 스타일 */
.citation-btn {
    background: #e3f2fd;
    color: #1976d2;
    border: 1px solid #bbdefb;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: 4px;
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.citation-btn:hover {
    background: #bbdefb;
    color: #1565c0;
    transform: translateY(-1px);
}

/* 인용 모달 스타일 */
.citations-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
}

.citations-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.citations-modal-content {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.citations-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
}

.citations-modal-header h3 {
    margin: 0;
    color: var(--primary-color);
    font-size: 1.2rem;
}

.citations-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.citations-modal-close:hover {
    background: #e0e0e0;
    color: #333;
}

.citations-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.citation-item {
    padding: 15px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: white;
}

.citation-item:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.citation-title {
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 8px;
    font-size: 1rem;
}

.citation-meta {
    display: flex;
    gap: 15px;
    color: #666;
    font-size: 0.85rem;
}

.citation-author {
    color: #1976d2;
}

.citation-date {
    color: #666;
}

.cd-skeleton {
    display: grid;
    gap: 12px;
}

.cd-skel-line {
    position: relative;
    overflow: hidden;
    background: #e7edf6;
    border-radius: 9px;
}

.cd-skel-line::after {
    content: '';
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.78), transparent);
    animation: cdShimmer 1.1s infinite;
}

.cd-skel-title {
    height: 34px;
    width: min(560px, 78%);
}

.cd-skel-meta {
    height: 22px;
    width: min(420px, 62%);
}

.cd-skel-card {
    height: 78px;
}

/* 본문/번역문의 개행 문자(\n)를 화면 줄바꿈으로 렌더링 */
.classic-content .original-text,
.classic-content .translation-text {
    white-space: pre-line;
}

@keyframes cdShimmer {
    to {
        transform: translateX(100%);
    }
}

/* 새 문장 삽입 폼의 입력창 — .form-group textarea 는 사이트 전역 클래스라
   여기서 .insert-form 안으로만 좁혀서 중립 톤으로 준다 */
.insert-form .form-group textarea {
    border: 1px solid #e6e7ea;
    border-radius: 8px;
    background: #fff;
    color: #1f2328;
}

.insert-form .form-group textarea:focus {
    border-color: #d3d5da;
    box-shadow: 0 0 0 3px rgba(31, 35, 40, 0.06);
}

/* 모바일 — 제목 줄과 컨트롤 묶음을 위아래로 가른다 */
@media (max-width: 768px) {
    .content-title.sticky {
        align-items: stretch;
        padding: 12px 16px;
        margin: -20px -20px 15px;
    }

    .classic-title-top {
        flex-direction: column;
        align-items: stretch;
        gap: 11px;
    }

    .classic-title-left {
        width: 100%;
    }

    .cd-actions {
        width: 100%;
        margin-left: 0;
        justify-content: space-between;
    }

    .volume-select-slot {
        flex: 1;
        justify-content: flex-end;
        min-width: 0;
    }

    .volume-select {
        flex: 1;
        max-width: none;
    }
}

@media (max-width: 550px) {
    .cd-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .cd-actions .edit-mode-switch {
        padding-right: 0;
        border-right: none;
    }

    .volume-select-slot {
        width: 100%;
    }
}
