.viewer-layout {
    flex: 1;
    display: flex;
    background: #e5e7eb;
    overflow: hidden;
}

.view-action-sidebar {
    flex: 1;
    background: #fff;
    border-left: 1px solid #e5e7eb;
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex-shrink: 0;
}

.side-action-title {
    font-size: 20px;
    font-weight: 800;
    color: #1e293b;
    letter-spacing: 0.5px;
}

.side-action-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.btn-side-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 30px;
    min-height: 280px;
    height: 30%;
    /* 400px 너비 대비 약 3:2 비율 (내부 좌우 여백 제외 실면적) */
    background: #f1f5f9;
    border: 2px solid #e2e8f0;
    border-radius: 24px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    text-align: center;
    width: 100%;
}

.btn-side-action.blue {
    background: #85a6d6;
    /* 파스텔 블루 */
    border-color: #dbeafe;
}

.btn-side-action.pink {
    background: #dd600b;
    /* 파스텔 로즈 */
    border-color: #ffe4e6;
}

.btn-side-action:hover {
    background: #fff;
    border-color: #3b82f6;
    box-shadow: 0 15px 35px rgba(59, 130, 246, 0.15);
    transform: translateY(-8px);
}

.btn-side-action.pink:hover {
    border-color: var(--action-pink);
    box-shadow: 0 15px 35px rgba(244, 63, 94, 0.2);
}


.side-icon {
    font-size: 70px;
    color: #fff;
    margin-bottom: 8px;
}

.side-text {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.side-text strong {
    font-size: 30px;
    font-weight: 900;
    color: #fff;
    letter-spacing: -0.5px;
}

.btn-side-action:hover strong {
    color: #1e293b;
}

.side-text span {
    font-size: 20px;
    color: #fff;
    line-height: 1.4;
    font-weight: 500;
}

.btn-side-action:hover span {
    color: #64748b;
}

@media screen and (max-width: 1024px) {
    .view-action-sidebar {
        width: 320px;
        padding: 20px;
    }
}


.view-main {
    flex: 1.5;
    overflow-y: auto;
    padding: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.view-paper {
    width: 100%;
    max-width: 1000px;
    background: #fff;
    min-height: 1200px;
    box-shadow: var(--shadow-float);
    border-radius: 12px;
    padding: 60px;
    display: flex;
    flex-direction: column;
    gap: 30px;
    flex-shrink: 0;
}

/* --- Maintenance Report Info Section --- */
.view-maint-info {
    padding-bottom: 30px;
    border-bottom: 1px solid #111;
    display: none;
    flex-direction: column;
    gap: 10px;
}

.view-maint-item {
    font-size: 15px;
    font-weight: 800;
    letter-spacing: -0.4px;
    color: #111;
}

.paper-header {
    border-bottom: 2px solid #111;
    padding-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.paper-title {
    font-size: 32px;
    font-weight: 900;
    letter-spacing: -1px;
    margin-bottom: 8px;
}

.paper-sub {
    font-size: 14px;
    color: #666;
}

.paper-header img {
    display: block;
    width: 200px;
}

.item-status-select {
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid #ddd;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    outline: none;
    appearance: none;
    text-align: center;
    transition: 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.item-status-select.request {
    color: #d97706;
    border-color: #fbbf24;
    background: #fffbeb;
}

.item-status-select.review {
    color: #2563eb;
    border-color: #93c5fd;
    background: #eff6ff;
}

.item-status-select.complete {
    color: #059669;
    border-color: #6ee7b7;
    background: #ecfdf5;
}

.view-content-row {
    display: flex;
    gap: 30px;
    align-items: flex-start;
    border-bottom: 1px solid #eee;
    padding-bottom: 20px;
    margin-bottom: 20px;
    position: relative;
}

.view-info-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.view-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.view-cat-badge {
    display: inline-block;
    font-size: 12px;
    font-weight: 800;
    color: #fff;
    background: #111;
    padding: 6px 14px;
    border-radius: 8px;
}



.view-url-container {
    font-size: 13px;
    color: #555;
    background: #f3f4f6;
    padding: 10px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: text;
    transition: 0.2s;
    border: 1px solid transparent;
}

.view-url-container:hover {
    background: #e5e7eb;
    border-color: #d1d5db;
}

.view-url-input {
    border: none;
    background: transparent;
    font-size: 13px;
    color: var(--primary);
    font-weight: 600;
    width: 100%;
    outline: none;
}

.view-memo-box {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.view-memo-item {
    margin-bottom: 8px;
    font-size: 14px;
    line-height: 1.6;
    display: flex;
    gap: 8px;
    word-break: break-all;
}

.view-memo-num {
    font-weight: 800;
    color: var(--action-pink);
    min-width: 32px;
}

.view-memo-text {
    white-space: pre-wrap;
    flex: 1;
}

.view-add-req {
    margin-top: 10px;
    font-size: 14px;
    color: #333;
    background: #fff1f2;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid #fecdd3;
    word-break: break-all;
}

.view-img-col {
    width: 400px;
    margin-top: 44px;
    flex-shrink: 0;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    background: #000;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.view-img-col img {
    width: 100%;
    display: block;
    height: auto;
}

.view-sidebar {
    background: #fff;
    border-left: 1px solid var(--bd);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-header {
    height: 64px;
    border-bottom: 1px solid var(--bd);
    display: flex;
    align-items: center;
    padding: 0 24px;
    font-weight: 800;
    font-size: 16px;
    gap: 8px;
}

.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: var(--chat-bg);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.chat-bubble {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 85%;
}

.chat-bubble.mine {
    align-self: flex-end;
    align-items: flex-end;
}

.chat-meta {
    font-size: 11px;
    color: #9ca3af;
    display: flex;
    gap: 6px;
}

.chat-text {
    padding: 12px 16px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
    color: #374151;
}

.chat-bubble.mine .chat-text {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    border-bottom-right-radius: 2px;
}

.chat-input-area {
    padding: 20px;
    background: #fff;
    border-top: 1px solid var(--bd);
}

.chat-input {
    width: 100%;
    height: 80px;
    padding: 12px;
    border: 1px solid var(--bd);
    border-radius: 8px;
    resize: none;
    font-size: 13px;
    outline: none;
    margin-bottom: 10px;
    background: #f9fafb;
}

.chat-input:focus {
    border-color: var(--primary);
    background: #fff;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

/* Footer */
.app-footer {
    background: var(--primary);
    color: #fff;
    padding: 15px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: #9ca3af;
    margin-top: auto;
}

/* --- Viewer Image Lightbox (Modal) --- */
.viewer-img-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 9999;
    display: none;
    /* Flex when active */
    justify-content: center;
    align-items: flex-start;
    /* 상단부터 시작하여 스크롤 용이하게 */
    padding: 80px 0 150px;
    backdrop-filter: blur(10px);
    overflow-y: auto;
    /* 모달 자체 스크롤 허용 */
}

.viewer-img-close {
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 40px;
    color: #fff;
    cursor: pointer;
    font-weight: bold;
    z-index: 10001;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    transition: 0.2s;
}

.viewer-img-close:hover {
    transform: scale(1.1);
}

.viewer-modal-container {
    position: relative;
    width: 80vw;
    /* 가로길이 80vw 고정 */
    max-width: 1400px;
    margin: auto;
    animation: slideUp 0.3s ease-out;
}

@media (max-width: 768px) {
    .viewer-modal-container {
        width: 95vw;
        margin: 0 auto;
    }
}

.viewer-canvas-wrapper {
    position: relative;
    display: inline-block;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    overflow: hidden;
    line-height: 0;
}

.viewer-img-content {
    width: 100%;
    height: auto;
    display: block;
}

.viewer-anno-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Annotation Rect */
.viewer-anno-rect {
    position: absolute;
    border: 2px solid #ef4444;
    border-radius: 2px;
    background: rgba(239, 68, 68, 0.05);
    pointer-events: auto;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
}

/* 상단 번호 뱃지 (캔버스 디자인 재현) */
.viewer-anno-rect::before {
    content: attr(data-num);
    position: absolute;
    top: 0;
    left: 0;
    width: 20px;
    height: 20px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

.viewer-anno-rect:hover,
.viewer-anno-rect.active {
    background: rgba(239, 68, 68, 0.2);
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.1), 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: #ef4444;
}

.viewer-anno-rect.is-purple {
    border-color: #8b5cf6;
    background: rgba(139, 92, 246, 0.05);
}

.viewer-anno-rect.is-purple::before {
    background: #8b5cf6;
}

.viewer-anno-rect.is-purple:hover,
.viewer-anno-rect.is-purple.active {
    background: rgba(139, 92, 246, 0.2);
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.1), 0 4px 12px rgba(0, 0, 0, 0.1);
}



/* Tooltip (Desktop) */
.viewer-memo-tooltip {
    position: fixed;
    z-index: 10010;
    top: 0;
    left: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
    width: auto;
    min-width: 280px;
    max-width: 50vw;
    pointer-events: none;
    font-size: 13px;
    line-height: 1.5;
    color: #333;
    animation: fadeIn 0.2s ease-out;
    /* 💡 컨테이너에 pre-wrap이 있으면 템플릿 리터럴의 줄바꿈이 그대로 보일 수 있으므로 제거 */
}

.viewer-memo-tooltip img {
    width: 100%;
    max-height: 50vh;
    object-fit: cover;
    object-position: top;
    border-radius: 6px;
    margin-top: 10px;
    display: block;
}

/* 이미지 하단 마스킹 효과 (300px 초과 시에만 작동하도록 로직 수정) */
.view-memo-img-wrapper {
    position: relative;
    overflow: hidden;
    margin-top: 10px;
    border-radius: 6px;
    max-height: 50vh;
    /* 컨테이너 높이 제한 */
}

.view-memo-img-wrapper.cropped::after {
    content: '';
    position: absolute;
    /* [핵심] 상단에서 (50vh - 40px) 지점에 고정. 
       이미지가 해당 높이에 도달하면 딱 하단 40px 영역에 걸쳐 보이게 됨. */
    top: calc(50vh - 40px);
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(to top, rgba(255, 255, 255, 0.95), transparent);
    pointer-events: none;
}

/* Bottom Sheet (Mobile) */
.viewer-bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    padding: 24px;
    padding-top: 10px;
    padding-bottom: 48px;
    z-index: 10002;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 -5px 25px rgba(0, 0, 0, 0.2);
    display: none;
    visibility: hidden;
    max-height: 50vh;
    min-height: 40vh;
    flex-direction: column;
    box-sizing: border-box;
}

.viewer-bottom-sheet.active {
    visibility: visible;
    transform: translateY(0);
}

.sheet-handle {
    width: 40px;
    height: 4px;
    background: #ddd;
    border-radius: 2px;
    margin: -10px auto 25px;
}

.sheet-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 32px;
    height: 32px;
    background: #f3f4f6;
    border: none;
    border-radius: 50%;
    font-size: 20px;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.sheet-content {
    font-size: 15px;
    line-height: 1.6;
    color: #333;
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}

.sheet-content img {
    width: 100%;
    border-radius: 12px;
    margin-top: 15px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Mobile Responsive (Viewer Mode) --- */
@media screen and (max-width: 768px) {
    .view-maint-info {
        padding-bottom: 10px;
        gap: 8px;
    }

    .view-maint-item {
        font-size: 13px;
    }
}

@media screen and (max-width: 768px) {
    #btnLandingCreate {
        display: none !important;
    }

    .viewer-layout {
        flex-direction: column;
        overflow-y: auto;
    }

    .view-action-sidebar {
        display: none;
    }

    .btn-side-action {
        padding: 16px;
    }

    .side-icon {
        font-size: 20px;
    }

    .side-text strong {
        font-size: 14px;
    }

    .side-text span {
        display: none;
    }

    .topbar {
        flex-direction: column;
        height: auto;
        padding: 10px 16px;
    }

    .logo-area img {
        width: 150px;
    }

    .top-msg {
        display: none;
    }

    .view-main {
        padding: 16px;
        overflow-y: visible;
    }

    .view-paper {
        padding: 24px;
        gap: 24px;
        min-height: auto;
    }

    .paper-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .paper-title {
        font-size: 20px;
    }

    .paper-header img {
        width: 120px;
    }

    .view-content-row {
        display: flex;
        flex-direction: column;
        gap: 16px;
        padding-bottom: 24px;
    }

    .view-info-col {
        display: contents;
    }

    .view-item-header {
        order: 1;
        margin-bottom: 8px;
    }

    .view-img-col {
        order: 2;
        width: 100%;
        margin: 0;
    }

    .view-url-container {
        order: 3;
    }

    .view-memo-box,
    .view-asset-items {
        order: 4;
    }

    .view-add-req {
        order: 5;
    }

    .app-footer {
        flex-direction: column;
        padding: 15px;
        gap: 8px;
        text-align: center;
    }
}