/* 뷰어 하이라이트(직접 칠한 것·AI)·메모 팝오버·삭제 되돌리기·빨간 띠. 모양·크기는 ASK 앱과 같고 색은 tokens.css를 쓴다. */
.pdf-viewer {
    /* 앱 danger(#B3412F)와 같은 빨강 */
    --hl-danger: #b3412f;
}

/* 원문 쪽 위 칠하기: 같은 색끼리 한 묶음에 불투명도 0.4(곱하기 합성 없음), 글자 고르기 층(z-index 1) 아래에 깐다.
   마우스를 받지 않고, 누르기는 쪽 칸 click에서 위치로 찾는다. */
.viewer-hl-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.viewer-hl-group {
    position: absolute;
    inset: 0;
}

.viewer-hl-box,
.viewer-hl-selected {
    position: absolute;
}

/* 새로 생긴 AI 하이라이트: 줄마다 왼쪽에서 오른쪽으로 칠해지듯 나타난다(지연·길이는 pdf-viewer.js가 정한다). */
.viewer-hl-box.is-sweep {
    clip-path: inset(0 100% 0 0);
    animation: viewer-hl-sweep var(--sweep-duration, 400ms) cubic-bezier(0.3, 0.7, 0.4, 1) var(--sweep-delay, 0ms) forwards;
}

@keyframes viewer-hl-sweep {
    to {
        clip-path: inset(0 0 0 0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .viewer-hl-box.is-sweep {
        clip-path: none;
        animation: none;
    }
}

/* 메모가 있는 하이라이트: 첫 상자 왼쪽 위의 점 */
.viewer-hl-dot {
    position: absolute;
    width: 10px;
    height: 10px;
    border: 1px solid #fff;
    border-radius: 50%;
    /* 앱 accent(#CC7D5E)와 같은 색 */
    background: var(--app-accent, #cc7d5e);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    transform: translate(-60%, -40%);
}

/* 고른 하이라이트: 상자마다 점선 */
.viewer-hl-selected {
    box-sizing: border-box;
    border: 2px dashed var(--app-accent, #cc7d5e);
    border-radius: 2px;
}

/* 선택 팝업: 형광펜 다섯 색 · 구분선 · 질문하기(앱 선택 팝업과 같다) */
.viewer-ask {
    gap: 4px;
}

.viewer-ask-swatches {
    display: flex;
    align-items: center;
    gap: 4px;
}

.viewer-ask-swatch {
    width: 22px;
    height: 22px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: transform 0.15s;
}

.viewer-ask-swatch:hover:not(:disabled) {
    transform: scale(1.1);
}

.viewer-ask-swatch:disabled {
    opacity: 0.4;
    cursor: default;
}

.viewer-ask-swatch:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.viewer-ask-divider {
    width: 1px;
    height: 16px;
    margin: 0 4px;
    background: rgba(39, 38, 30, 0.11);
}

/* 하이라이트 메모 팝오버: 쪽 칸 안에 비율 자리로 띄워 스크롤을 따라간다. 글자 층(1)·머리 줄(2) 위, 휴대폰 시트 아래. */
.viewer-hl-pop {
    position: absolute;
    z-index: 3;
    width: 288px;
    max-width: calc(100vw - 16px);
    border-radius: 12px;
    background: var(--paper);
    color: var(--ink);
    box-shadow:
        0 8px 24px color-mix(in srgb, var(--ink) 14%, transparent),
        0 0 0 1px var(--line);
    font-size: 13px;
    text-align: left;
    cursor: auto;
    -webkit-touch-callout: default;
}

.viewer-hl-pop[data-placement="above"] {
    transform: translate(-50%, -100%) translateY(-10px);
}

.viewer-hl-pop[data-placement="below"] {
    transform: translate(-50%, 0) translateY(10px);
}

.viewer-hl-pop-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 6px 0 14px;
}

.viewer-hl-pop-title {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    color: var(--ink-faint);
    font-size: 12px;
}

.viewer-hl-pop-swatch {
    flex: none;
    width: 10px;
    height: 10px;
    border-radius: 3px;
}

.viewer-hl-pop-page {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.viewer-hl-pop-actions {
    display: flex;
    align-items: center;
}

.viewer-hl-pop-btn {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--ink-soft);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.viewer-hl-pop-btn svg {
    width: 16px;
    height: 16px;
}

.viewer-hl-pop-btn:hover:not(:disabled) {
    background: color-mix(in srgb, var(--ink) 5%, transparent);
    color: var(--ink);
}

.viewer-hl-pop-delete:hover:not(:disabled) {
    color: var(--hl-danger);
}

.viewer-hl-pop-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.viewer-hl-pop-btn:focus-visible,
.viewer-hl-undo-btn:focus-visible,
.viewer-hl-banner-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.viewer-hl-pop-body {
    padding: 4px 12px 10px;
}

.viewer-hl-pop-input {
    display: block;
    width: 100%;
    height: 112px;
    padding: 8px 12px;
    border: 0;
    border-radius: 8px;
    background: var(--bg);
    color: var(--ink);
    font: inherit;
    font-size: 13px;
    line-height: 24px;
    resize: none;
    outline: none;
}

.viewer-hl-pop-input::placeholder {
    color: var(--ink-faint);
}

.viewer-hl-pop-input:focus {
    box-shadow: 0 0 0 1px var(--line-strong);
}

.viewer-hl-pop-input:disabled {
    opacity: 0.6;
}

.viewer-hl-pop-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
    color: var(--ink-faint);
    font-size: 11.5px;
}

.viewer-hl-pop-status {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.viewer-hl-pop-status.error {
    color: var(--hl-danger);
}

.viewer-hl-pop-count {
    flex: none;
}

/* 지운 하이라이트 되돌리기(5초): 아래 가운데의 어두운 띠 */
.viewer-hl-undo {
    position: fixed;
    left: 50%;
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-radius: 10px;
    background: var(--ink);
    color: var(--bg);
    box-shadow:
        0 8px 24px color-mix(in srgb, var(--ink) 14%, transparent),
        0 0 0 1px var(--line);
    font-size: 13px;
    white-space: nowrap;
    transform: translateX(-50%);
    animation: viewer-hl-undo-in 0.18s ease-out;
}

.viewer-hl-undo-btn {
    padding: 0;
    border: 0;
    background: transparent;
    /* 앱 accent(#CC7D5E): 어두운 띠 위에서도 읽힌다 */
    color: #cc7d5e;
    font: inherit;
    cursor: pointer;
    transition: opacity 0.15s;
}

.viewer-hl-undo-btn:hover {
    opacity: 0.8;
}

@keyframes viewer-hl-undo-in {
    from {
        opacity: 0;
    }
}

/* 하이라이트를 불러오지 못했거나 다른 곳에서 바뀌었을 때 위쪽 막대 아래에 뜨는 빨간 띠 */
.viewer-hl-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 16px;
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--hl-danger) 10%, var(--surface));
    color: var(--hl-danger);
    font-size: 12.5px;
    line-height: 1.5;
}

.viewer-hl-banner-btn {
    flex: none;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}

@media (max-width: 759px) {
    .viewer-hl-banner {
        padding: 8px 12px;
    }

    .viewer-hl-undo {
        bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    }
}

@media (prefers-reduced-motion: reduce) {
    .viewer-hl-undo {
        animation: none;
    }
}
