* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;

    overflow: hidden;
}

div {
    display: block;
}

.header {
    position: relative;
    top: 0;
    background: #fff;
    border-bottom: 1px solid #e6e6e6;
}

.header-contain {
    display: flex;
    height: 7vh;
    justify-content: center;
    padding: 5px;
}

.header-contain>img {
    cursor: pointer;
}



.container {
    width: 100%;
    height: 100%;
    margin: 0 auto;
    display: flex;
    height: 100%;
    flex-direction: row;
}

.container-main {
    width: 80vw;
    background-color: #494a5a;
}

#viewer {
    width: auto;    /* Automatically adjust the width */
    overflow: hidden; /* Hide any overflow */
    margin: auto;
    text-align: center;

}

#footer {
    position: absolute;
    height: 16px;
    width: 100%;
    bottom: 5px;
    overflow: hidden;
    color: rgb(214, 214, 214);
    text-align: left;
    padding: 0px 0px 0px 10px;
    font-size: 7px;
    z-index: 1;
}

.container-opt {
    height: 100vh;
    width: 20vw;
    border-left: 1px solid #e6e6e6;
    box-shadow: 0 .5px 5px 1px #d8d8d8;
    background-color: #fff;
    min-height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    z-index: 5;
}

.opt_content {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
}

.tab {
    width: 100%;
    position: relative;
    display: block;
}

.tab-btn-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    align-items: center;
    text-align: center;
    background-color: #fff;
    border: 1px solid #e6e6e6;
}

.tab-btn {
    display: inline-block;
    color: #6d757a;
    cursor: pointer;
    font-size: 1vw;
    font-weight: 800;
}

.tab-btn>a {
    display: block;
    width: 100%;
    text-decoration: none;
    color: inherit;
    padding: 8px 0;
}

.tab-btn>a:hover {
    background-color: rgb(173, 186, 199, 0.15);
    border-radius: 5px;
}

.btn-selecting {
    border-bottom: 3px solid rgba(54, 116, 198, 0.8);
}

.tab-content {
    display: none;
    flex-direction: column;
    overflow: auto;

    /* gap: 10px; */
    /* padding: 10px 10px; */
    animation: SlideIn .2s;
    height: 100%;
}

.shown {
    display: flex;
}


.add-model-block {
    border-bottom: 1px solid #e6e6e6;
    display: grid;
    grid-template-columns: 4fr 1fr;
    align-items: center;
    justify-items: center;
    grid-row-gap: 5px;
    padding: 10px;
}

.circle-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 50px;
    height: 50px;
    line-height: 45px;
    text-align: center;
    padding: 0;
    border-radius: 50%;
    background-color: transparent;
    font-size: 1.5vw;
    margin: 0.25rem !important;
    cursor: pointer;
}

.add-btn {
    grid-column: 2 / 3;
    grid-row: 1 / 4;
    border: 1px solid rgba(54, 116, 198, 1);
    color: rgba(54, 116, 198, 1);
}

.add-btn:hover {
    background-color: rgba(54, 116, 198, 1);
    color: #fff;
}

.char-select {
    width: 95%;
    grid-column: 1 / 2;
    grid-row: 2 / 3;
}

.costume-select {
    width: 95%;
    grid-column: 1 / 2;
    grid-row: 3 / 4;
}

.select-title {
    margin: 2px 5px;
}

select {
    width: 100%;
    height: 5vh;
    border: 1px solid #e6e6e6;
    padding-left: 5px;
    border-radius: 5px;
    font-weight: 400;
    font-size: 1rem;
}

.Models-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px 10px 20px 10px;
    height: 100%;
    overflow: auto;
    /* overflow-x: hidden;
    overflow-y: auto; */
}

.modelInfoBlock {
    background: #fff;
    border-radius: 5px;
    border: 1px solid #e6e6e6;
    border-left: 4px solid rgba(54, 116, 198, 0.8);
    display: grid;
    grid-template-columns: 3fr 1fr;
    grid-template-rows: 3fr 2fr;

}

.model-remove-btn {
    grid-column: 2/3;
    grid-row: 2/3;
    background-color: transparent;
    border: 1px solid transparent;
    border-left: 1px solid #e6e6e6;
    font-size: 1vw;
    display: flex;
    justify-content: center;
    align-items: center;
    color: rgb(252, 86, 86);
}

.model-remove-btn:hover {
    background-color: rgb(252, 86, 86);
    color: #fff
}

.model-setting-btn {

    grid-column: 2/3;
    grid-row: 1/2;
    background-color: transparent;
    border: 1px solid transparent;
    border-left: 1px solid #e6e6e6;
    border-bottom: 1px solid #e6e6e6;
    font-size: 1vw;
    display: flex;
    justify-content: center;
    align-items: center;
}

.model-setting-btn:hover {
    background-color: rgb(173, 186, 199, 0.15);
}

.ModelName {
    margin: auto;
    font-size: 1.8rem;
    padding-top: 3px;
}

.CostumeName {
    margin: auto;
    font-size: 0.8rem;
    padding-bottom: 3px;
}

.info {
    display: grid;
    grid-template-columns: 1fr 5fr;
    justify-items: center;
    align-items: center;
    padding: 5px;
    border-bottom: 1px solid #e6e6e6;
}

.color-info {
    grid-column: 1 / 4;
    display: grid;
    grid-template-rows: 1fr 1fr;
    align-items: center;
    padding: 8px;
    border-bottom: 1px solid #e6e6e6;
    font-size: large;
}

.colorPicker {
    width: 100%;
}

.back-btn {
    grid-column: 1 / 2;
    grid-row: 1 / 3;
    border: 1px solid #bebebe;
    color: #bebebe;
}

.back-btn:hover {
    background-color: #bebebe;
    color: rgb(249, 193, 193);
}

#ModelsSettingList {
    padding: 0px 0px 20px 0px;
    gap: 0px;
}


.collapsible {
    background-color: #f9f9f9;
    cursor: pointer;
    padding: 15px;
    width: 100%;
    border: none;
    text-align: left;
    outline: none;
    font-size: large;
    border-bottom: 1px solid #e6e6e6;
    user-select: none;
}

.active,
.collapsible:hover {
    background-color: #e6e6e6;
}

.collapsible:after {
    content: '\002B';
    font-weight: bold;
    float: right;
    margin-left: 5px;
}

.active:after {
    content: "\2212";
}

.collapsible-content {
    display: none;
}

.collapsible-list {
    padding: 15px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    user-select: none;
}


.collapsible-list>button {
    width: 100%;
    border-radius: 7px;
    background: rgba(54, 116, 198, 0.8);
    border: 1px solid #ccc;
    box-shadow: 0 0 10px rgba(145, 145, 149, 0.1);
    padding: 5px;
    font-weight: 500;
    color: #e5f5ff;
    font-size: large;
    text-align: center;
}

.collapsible-list>button:hover {
    background: rgba(49, 91, 156, 0.8);
    border: 1px solid #ccc;
}

.rangeOption {
    width: 100%;
    display: grid;
    grid-template-columns: 4fr 1fr;
    grid-template-rows: 1fr 1fr;
    align-items: center;
    grid-column-gap: 5px;
    padding: 0 5px 5px 5px;
    border-bottom: 1px solid #e6e6e6;
}

.rangeOption>p {
    grid-column: 1 / 3;
    grid-row: 1 / 2;
    padding-left: 10px;
}

.rangeOption>input[type='range'] {
    width: 95%;
    grid-column: 1 / 2;
    grid-row: 2 / 3;
    margin: auto;
    outline: none;
    background: #d3d3d3;
    -webkit-appearance: none;
    appearance: none;
    height: 25%;
    border-radius: 25px;
}

.rangeOption>input[type='number'] {
    width: 100%;
    height: 100%;
    grid-column: 2 / 3;
    grid-row: 2 / 3;
    font-size: medium;
    text-align: center;
}

.checkBoxOption {
    width: 100%;
    display: grid;
    grid-template-columns: 4fr 1fr;
    align-items: center;
    grid-column-gap: 5px;
    padding: 0 5px 5px 5px;
    border-bottom: 1px solid #e6e6e6;
}

.checkbox-text {
    background-color: #f9f9f9;
    padding: 15px;
    width: 100%;
    border: none;
    text-align: left;
    outline: none;
    font-size: large;
    display: grid;
    grid-template-columns:17fr 1fr;
    align-items: center;
    grid-column-gap: 5px;
    border-bottom: 1px solid #e6e6e6;
}
.checkBoxOption>p {
    grid-column: 1 / 2;
    padding-left: 10px;
}

.checkBoxOption>input[type='checkbox'] {
    grid-column: 3 / 4;
    font-size: medium;
    text-align: center;
}
.checkbox-text>input[type='checkbox'] {
    width: 100%;
    height: 100%;
    grid-column: 2 / 3;
    font-size: medium;
    text-align: center;
}
.text-container {
    position: fixed;
    bottom: 20px;
    left: 40%;
    transform: translateX(-50%);
    padding: 10px;
    background: linear-gradient(50deg, rgba(136, 137, 139, 0.2),rgba(136, 137, 139, 0.3) );
    max-width: 700px;
    word-wrap: break-word;
    z-index: 100;
    opacity: 0;
    border-radius: 2px;
    transition: opacity 0.5s ease-in-out;
    color: #e5f5ff;
}


#background-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
}

#tips {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 20px;
    background-color: #f0f0f0;
    border: 1px solid #ccc;
    text-align: center;
    z-index: 1000;
    border-radius: 7px;
}

#tipsCloseButtonContainer {
    margin-top: 20px;
}

#tipsCloseButton {
    padding: 10px;
    background-color: rgba(54, 116, 198, 0.8);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}


@keyframes SlideIn {
    0% {
        opacity: 0;
        -webkit-transform: translateX(-50px);
        transform: translateX(-50px);
    }

    100% {
        opacity: 1;
        -webkit-transform: translateX(0);
        transform: translateX(0);
    }
}

@media only screen and (max-width: 1024px) {
    body {
        overflow: unset !important;
    }

    * {
        font-size: 3.5vw;
    }

    .container {
        flex-direction: column;
    }

    .container-main {
        width: 100%;
        margin: 0 auto;
        display: flex;
        height: 55vh;
        flex-direction: row;
    }

    .container-opt {
        width: 100%;
        height: 45vh;
        min-height: 45vh !important;

    }

    .opt_content {
        display: flex;
        flex-direction: column;
        height: 100%;
        overflow-y: auto;
        overflow-x: hidden;
    }

    #viewer {
        padding: 0 !important;
        width: 100%;
    }

    .circle-btn {
        width: 35px;
        height: 35px;
    }

    .collapsible,
    .motion-list>button {
        font-size: 3.5vw;
    }

    .ModelName {
        margin: auto;
        font-size: 1.5rem;
        padding-top: 3px;
    }
    
    .CostumeName {
        margin: auto;
        font-size: 0.6rem;
        padding-bottom: 3px;
    }

    .text-container {
        position: fixed;
        bottom: 46%;
        left: 50%;
        right: -20%;
        padding: 8px;
        background: linear-gradient(50deg, rgba(136, 137, 139, 0.2),rgba(136, 137, 139, 0.3) );
        word-wrap: break-word;
        z-index: 1000;
        opacity: 0;
        border-radius: 7px;
        transition: opacity 0.5s ease-in-out;
        color: #e5f5ff;
    }
}

#loading-tip {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    animation: fadeIn 0.3s;
}

.loading-content {
    background: white;
    padding: 30px 50px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.loading-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid rgba(54, 116, 198, 0.8);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

.loading-model-name {
    color: #666;
    font-size: 0.9em;
    margin-top: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.fade-out {
    animation: fadeOut 0.3s forwards;
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}
.part-global-controls {
    display: flex;
    gap: 10px;
    background: #ffffff;
}

.part-all-on-btn,
.part-all-off-btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 5px;
    font-weight: 520;
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
}

.part-all-on-btn {
    background: rgba(54, 116, 198, 0.8);
    color: white;
}

.part-all-on-btn:hover {
    background: rgba(54, 116, 198, 0.8);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(76, 175, 80, 0.3);
}

.part-all-off-btn {
    background: linear-gradient(135deg, #f44336, #ef5350);
    color: white;
}

.part-all-off-btn:hover {
    background: linear-gradient(135deg, #d32f2f, #f44336);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(244, 67, 54, 0.3);
}

/* ============ 部件网格容器 ============ */
.part-grid-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* 固定每行3个 */
    gap: 10px;
    padding: 15px;
}

/* ============ 部件卡片 ============ */
.part-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 25px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    background: white;
}

/* 显示状态 */
.part-card.part-visible {
    background: rgba(54, 116, 198, 0.8);
}

.part-card.part-visible:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(54, 116, 198, 0.8);
}

.part-card.part-visible .part-name {
    color: #ffffff;
}

/* 隐藏状态 */
.part-card.part-hidden {
    background: linear-gradient(135deg, #ffebee, #fce4ec);
    border-color: #f44336;
    opacity: 0.7;
}

.part-card.part-hidden:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(244, 67, 54, 0.3);
    border-color: #d32f2f;
    opacity: 1;
}

/* ============ 部件名称 ============ */
.part-name {
    font-size: 0.85em;
    font-weight: 520;
    text-align: center;
    color: #000000;
    margin-bottom: 8px;
    word-break: break-word;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;   
    -webkit-box-orient: vertical;
    max-width: 100%;
    user-select: none;
}


/* ============ 详细设置按钮 ============ */
.part-detail-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: gray;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.3s ease;
    font-size: 0.8em;
}

.part-card:hover .part-detail-btn {
    opacity: 1;
}

.part-detail-btn:hover {
    background: rgba(49, 91, 156, 0.9);
    transform: scale(1.1);
}

/* ============ 弹窗样式 ============ */
.part-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

.part-modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 450px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

.part-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 2px solid #e6e6e6;
}

.part-modal-header h3 {
    margin: 0;
    color: #333;
    font-size: 1.3em;
    word-break: break-word;
}

.part-modal-close {
    width: 35px;
    height: 35px;
    border: none;
    background: #f5f5f5;
    border-radius: 50%;
    font-size: 1.5em;
    cursor: pointer;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.part-modal-close:hover {
    background: #e0e0e0;
    transform: rotate(90deg);
}

.part-modal-body {
    padding: 25px;
}

.part-detail-control label {
    display: block;
    font-weight:520;
    margin-bottom: 15px;
    color: #555;
    font-size: 1.1em;
}

.part-slider-group {
    display: grid;
    grid-template-columns: 3fr 1fr;
    gap: 10px;
    align-items: center;
    margin-bottom: 20px;
}

.part-detail-range {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.part-detail-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(54, 116, 198, 0.8);
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.part-detail-range::-webkit-slider-thumb:hover {
    background: rgba(49, 91, 156, 0.9);
    transform: scale(1.2);
}

.part-detail-number {
    width: 100%;
    padding: 8px;
    border: 2px solid #e6e6e6;
    border-radius: 5px;
    text-align: center;
    font-size: 1em;
    font-weight: 600;
}

.part-detail-number:focus {
    border-color: rgba(54, 116, 198, 0.8);
    outline: none;
}

.part-preset-buttons {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.part-preset-buttons button {
    padding: 10px 5px;
    border: 2px solid #e6e6e6;
    background: white;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 600;
    color: #666;
    transition: all 0.3s ease;
}

.part-preset-buttons button:hover {
    background: rgba(54, 116, 198, 0.1);
    border-color: rgba(54, 116, 198, 0.8);
    color: rgba(54, 116, 198, 0.8);
    transform: translateY(-2px);
}

.part-modal-footer {
    display: flex;
    gap: 10px;
    padding: 15px 20px;
    border-top: 2px solid #e6e6e6;
    background: #f9f9f9;
    border-radius: 0 0 12px 12px;
}

.part-modal-reset,
.part-modal-confirm {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.part-modal-reset {
    background: #f5f5f5;
    color: #666;
}

.part-modal-reset:hover {
    background: #e0e0e0;
    transform: translateY(-2px);
}

.part-modal-confirm {
    background: rgba(54, 116, 198, 0.8);
    color: white;
}

.part-modal-confirm:hover {
    background: rgba(49, 91, 156, 0.9);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(54, 116, 198, 0.3);
}

/* ============ 动画 ============ */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ============ 响应式设计 ============ */
@media only screen and (max-width: 1024px) {
    .part-grid-container {
        grid-template-columns: repeat(3, 1fr); /* 移动端每行2个 */
        gap: 9px;
        padding: 0px;
    }
    
    .part-card {
        padding: 5px 5px;
    }
    
    .part-name {
        font-size: 0.9em;
    }
  
    
    .part-detail-btn {
        width: 24px;
        height: 24px;
        font-size: 0.7em;
    }
    
    .part-modal-content {
        width: 95%;
        max-width: none;
    }
    
    .part-preset-buttons {
        grid-template-columns: repeat(3, 1fr);
    }
}

#motion-list {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 15px 10px;
}

#motion-list > button {
    width: 100%;
    border-radius: 7px;
    background: rgba(54, 116, 198, 0.8);
    border: 1px solid #ccc;
    box-shadow: 0 0 10px rgba(145, 145, 149, 0.1);
    padding: 10px 5px;
    font-weight: 500;
    color: #e5f5ff;
    font-size: 0.85em;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    word-break: break-word;
    min-height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#motion-list > button:hover {
    background: rgba(49, 91, 156, 0.9);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(54, 116, 198, 0.4);
}

#motion-list > button:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(54, 116, 198, 0.3);
}

/* 表情列表也使用网格布局 */
#expressions-list {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 15px 10px;
}

#expressions-list > button {
    width: 100%;
    border-radius: 7px;
    background: rgba(54, 116, 198, 0.8);
    border: 1px solid #ccc;
    box-shadow: 0 0 10px rgba(145, 145, 149, 0.1);
    padding: 10px 5px;
    font-weight: 500;
    color: #e5f5ff;
    font-size: 0.85em;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    word-break: break-word;
    min-height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#expressions-list > button:hover {
    background: rgba(49, 91, 156, 0.9);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(54, 116, 198, 0.4);
}

#expressions-list > button:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(54, 116, 198, 0.3);
}

/* 移动端适配 - 改为每行2个 */
@media only screen and (max-width: 1024px) {
    #motion-list,
    #expressions-list {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 10px;
    }
    
    #motion-list > button,
    #expressions-list > button {
        font-size: 0.9em;
        padding: 12px 8px;
        min-height: 50px;
    }
}