html, body {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    /* gap:10px; */
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;   
    overflow: hidden;  
    user-select: none; /* 禁止选择文本 */     
    opacity: 1;
    transition: opacity 0.3s ease;
}

body.loading {
    opacity: 1;
}

#ggbTitleBar {
    display: flex;
    justify-content: space-between;
    /* width: 100%; */
    height: 4.5vh;
    font-size: max(1.3vw, 1.3vh);
    font-weight: bold;
    color:#2253bd;    
    background-color: #ddd;
    border-bottom: 1px solid #ccc;
    box-shadow: 0 3px 8px #aaa;    
    text-shadow: 1px 1px  white;
    z-index: 1001;
}

#ggbTitleBar #ggbTitle {
    line-height: 4.5vh;
    padding-left: 1vw;    
}

#ggbTitleBar #systemTime {
    color:black;
    line-height: 4.5vh;
    padding-right: 1vw;        
    font-size: 0.8vw;
}


#app123 {    
    flex: 1;
    box-sizing: border-box;
    width: 100%;          
}

#ggbContainer {
    margin: 0 auto;
}

/* Loading indicator styles */
#loadingIndicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999;
    background-color: rgba(255, 255, 255, 0.95);
    padding: min(4vw, 4vh);
    border-radius: min(2vw, 2vh);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    visibility: visible;
}

.spinner {
    position: relative;
    width: min(10vw, 10vh);
    height: min(10vw, 10vh);
}

.ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: min(0.6vw, 0.6vh) solid transparent;
    border-radius: 50%;
    animation: spin 1.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
}

.ring:nth-child(1) {
    border-top-color: #2253bd;
    animation-delay: 0s;
}

.ring:nth-child(2) {
    border-right-color: #2253bd;
    animation-delay: 0.5s;
}

.ring:nth-child(3) {
    border-bottom-color: #2253bd;
    animation-delay: 1s;
}

@keyframes spin {
    0% {
        transform: rotate(0deg) scale(1);
    }
    50% {
        transform: rotate(180deg) scale(0.8);
    }
    100% {
        transform: rotate(360deg) scale(1);
    }
}

/* 移除旧的loader相关样式 */
.loader, .loader-text {
    display: none;
}

/* 移除旧的点动画相关样式 */
.dot {
    display: none;
}

/* =================工具栏样式 =================*/
#toolbar {    
    position: absolute;
    display: flex;
    gap: 0.5vw;
    align-items: center;
    background-color: white;    
    border-radius: 0.5vw;
    border: 1px solid #ccc;    
    box-shadow: 0 0 1vw 0 rgba(0, 0, 0, 0.3);
    padding: 0.5vw;
    z-index: 1000;
}

.horizontal {
    flex-direction: row;
    padding: 0.3vw 0.6vw;
}

.vertical {
    flex-direction: column;
    padding: 0.4vw;
}

#toolbar {
    gap: 0.3vw;
}

#toolbar.horizontal {
    flex-direction: row;
}

#toolbar.vertical {
    flex-direction: column;
}

#dragArea {
    width: clamp(24px, 2.5vw, 40px);
    height: clamp(24px, 2.5vw, 40px);
    cursor: move;    
    display: flex;
    justify-content: center;
    align-items: center;
}

#pages {    
    width: clamp(24px, 2.5vw, 40px);
    height: clamp(24px, 2.5vw, 40px);    
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;    
    border-radius: 20%;
    background-color: #aaa;
}

#pages > span {
    display: inline-block;
    padding: 0.5vw;    
    color: #fff;        
    font-size: clamp(12px, 1vw, 16px);
    font-weight: bold;    
}

#toolbar button {
    width: clamp(28px, 3vw, 48px);
    height: clamp(28px, 3vw, 48px);
    margin: 0;
    outline: none;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    border: none;
    background: transparent;    
    transition: background-color 0.3s;
}

#toolbar button svg {
    width: clamp(16px, 2vw, 32px);
    height: clamp(16px, 2vw, 32px);
}

#toolbar button:not([disabled]):hover {
    border-radius: 5px;
    background-color: #2253bd;
}
#toolbar button:not([disabled]):hover svg path{
    stroke: #fff;
}

#toolbar button:not([disabled]):active {
    border-radius: 5px;
    background-color: #2e2f74;
}

#toolbar button:not([disabled]):active svg path {
    stroke: #fff;
}

#toolbar button[disabled] {
    cursor: not-allowed;    
}

#toolbar button[disabled] svg path {
    stroke: #ccc;
}

#toolbar button svg {
    width: 80%;
    height: 80%;
}

/* 复选框样式 */
/* Checkbox container - 设置为圆形，添加边框，居中对齐内容 */
.checkbox-container {
    width: max(1vw, 16px);
    height: max(1vw, 16px);
    border-radius: 50%;
    border: max(0.1vw, 2px) solid #bdb6b6;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s; /* 平滑过渡效果 */
    background-color: white; /* 默认背景色 */
    cursor: pointer;     
}

/* 隐藏原生checkbox */
.checkbox-container input[type="checkbox"] {
    display: none;
}

/* 选中时的样式 */
.checkbox-container input[type="checkbox"]:checked + .checkmark {
    background-color: #3dd838; /* 选中时的背景色为蓝色 */
}

/* 自定义的勾选标记样式 */
.checkmark {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%; /* 圆形 */
}

/* =================工具栏样式 END =================*/

/* 修改弹出菜单样式 */
.popup-menu {
    position: fixed;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    display: none;
    min-width: 12vw;
    max-width: 20vw;
    max-height: 80vh;
    overflow-y: auto;
    font-size: 0.9vw;    
    z-index: 2000;
}

.popup-menu ul {
    list-style: none;
    margin: 0;
    padding: 0.8vh 0;
}

.popup-menu li {
    padding: 0.2vh 0.3vw 0.5vh 0.3vw;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.popup-menu li span {
    display: inline-block;
    width: 5%;
}

.popup-menu li:hover {
    color: #fff;
    background: #2253bd;
}

.popup-menu li:active {
    color: white;
    background: #321e8b;
}

/* 添加遮罩层样式 */
#overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    display: none;
    z-index: 999; /* 确保在GGB上方，但在菜单下方 */
}

/**============对话框样式=======================*/
/* 遮罩样式 */
.dlg_overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

/* 弹出框样式 */
.dlg_popup {
    padding: 0.5vw; /* 使用视口宽度单位 */
    background: #fff;
    border-radius: 0.5vw;
    box-shadow: 0 0.4vw 0.6vw rgba(0, 0, 0, 0.1);
    /* width: 40%; 弹出框宽度为视窗宽度的50% */
    max-width: 600px; /* 最大宽度限制 */
    min-width: 300px; /* 最小宽度限制 */
    font-size: 0.8vw; /* 字体大小也使用视口宽度单位 */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.dlg_popup-text{
    color: red;
    width: 100%;
    height: 3vh;
    line-height: 3vh;
    text-align: center;    
    font-weight: bold;
    border-bottom: #aaa 1px solid;
    padding-bottom: 1vh;  
    font-size: 1vw;  
}

/* 按钮样式 */
.dlg_popup-button {
    padding: 0.5vw 1vw;
    border: solid 1px #aaa;
    background: white;
    color: black;
    border-radius: 0.5vw;
    cursor: pointer;
    margin-top: 1vw;
    /* font-size: 0.7vw; */
}

.dlg_popup-button:hover {
    box-shadow: 0 0 0.6vw rgba(0, 0, 0, 0.1);
}

/* 涂鸦按钮默认状态 */
#drawBtn {
  /* margin: 0 1vw !important; 增加左右边距到1vw */
  border-bottom: 0.3vw solid var(--current-pen-color, #FF0000) !important; /* 始终显示当前笔色 */
}

/* 涂鸦按钮激活状态 */
#drawBtn.active {
  background-color: #f0e0d6 !important; /* 暖灰色 */
  border-radius: 5px !important;
}

/* 涂鸦按钮激活状态下的SVG路径颜色 */
#drawBtn.active svg path {
  stroke: #ffffff !important; /* 保持图标为白色 */
}

/* 涂鸦选项面板样式 */
.draw-panel {
  position: absolute;
  background: white;
  border: 1px solid #ccc;
  border-radius: 0.3vw;
  padding: 0.4vw;
  box-shadow: 0 0.2vw 1vw rgba(0,0,0,0.1);
  z-index: 1000;
  max-height: 80vh;
  overflow-y: auto;
  overflow-x: hidden; /* 防止横向滚动条 */
  width: auto; /* 自适应内容宽度 */
  box-sizing: border-box; /* 确保padding不会增加总宽度 */
  transition: opacity 0.2s ease;
}

/* 颜色选项样式 */
.color-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2vw;
  margin-bottom: 0.3vw;
  justify-content: center;
}

/* 颜色按钮样式 */
.color-btn {
  width: 1.2vw;
  height: 1.2vw;
  border-radius: 50%;
  cursor: pointer;
  border: 0.1vw solid #ddd;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.color-btn.active::after {
  content: '';
  position: absolute;
  width: 0.5vw;
  height: 0.3vw;
  border-left: 0.12vw solid white;
  border-bottom: 0.12vw solid white;
  transform: rotate(-45deg) translateY(-0.05vw);
}

/* 为黑色按钮特别设置对号颜色 */
.color-btn:nth-child(1).active::after {
  border-color: #fff;
}

/* 为绿色按钮特别设置对号颜色 */
.color-btn:nth-child(3).active::after {
  border-color: #000;
}

/* 为浅色按钮特别设置对号颜色 */
.color-btn:nth-child(5).active::after {
  border-color: #000;
}

/* 设置预设颜色 */
.color-btn:nth-child(1) { background-color: #000000; }
.color-btn:nth-child(2) { background-color: #FF0000; }
.color-btn:nth-child(3) { background-color: #00FF00; }
.color-btn:nth-child(4) { background-color: #0000FF; }
.color-btn:nth-child(5) { background-color: #FFA500; } /* 橙色 */
.color-btn:nth-child(6) { background-color: #cc36cc; } /* 紫色 */

/* 滑动条容器 */
.slider-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3vw;
  font-size: 0.8vw;
  width: 100%;
  padding: 0.3vw 0;
  box-sizing: border-box;
}

/* 滑动条样式 */
.slider {
  width: 75%;
  height: 0.3vw;  
  background: #ddd;
  border-radius: 0.15vw;
  outline: none;
}

/* 滑动条滑块样式 */
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 1vw;
  height: 1vw;
  background: #2253bd;
  border-radius: 50%;
  cursor: pointer;
}

.slider::-moz-range-thumb {
  width: 1vw;
  height: 1vw;
  background: #2253bd;
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

/* 橡皮擦按钮默认状态 */
#eraserBtn svg path {
    transition: stroke 0.3s ease;
}

/* 橡皮擦按钮激活状态 */
#eraserBtn.active {
    background-color: #f0e0d6 !important; /* 与涂鸦按钮保持一致 */
    border-radius: 5px !important;
}

#eraserBtn.active svg path {
    stroke: #ffffff !important;
}

/* 画笔光标 */
#drawCanvas.pen-mode {
    cursor: url("data:image/svg+xml,%3Csvg width='32' height='32' viewBox='0 0 48 48' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M30.9995 8.99902L38.9995 16.999' stroke='%23000000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M7.99953 31.999L35.9994 4L43.9995 11.999L15.9995 39.999L5.99951 41.999L7.99953 31.999Z' stroke='%23000000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M8.99951 31.999L15.9995 38.999' stroke='%23000000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M12.9995 34.999L34.9995 12.999' stroke='%23000000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") 4 28, crosshair;
}

/* 橡皮擦光标 */
#drawCanvas.eraser-mode {
    cursor: default;
}


/* #eraserBtn.disabled:hover svg path {
    stroke: #ccc !important;
} */

/* 修改按钮悬停样式，排除禁用状态的橡皮擦按钮 */
#toolbar button:not([disabled]):hover {
    border-radius: 5px;
    background-color: #2253bd;    
}

#toolbar button:not([disabled]):hover svg path {
    stroke: #fff;
}

/* 滑动条自适应样式 */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: #d3d3d3;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid #888;
  cursor: pointer;
  box-shadow: 0 0 2px rgba(0,0,0,0.3);
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid #888;
  cursor: pointer;
  box-shadow: 0 0 2px rgba(0,0,0,0.3);
}

/* 为画笔和橡皮擦面板中的滑动条添加特定样式 */
#drawPanel input[type="range"], 
#eraserPanel input[type="range"] {
  margin: 0.5vw 0;
  width: 75%;
}

/* 滑动条数值显示的样式 */
#sizeValue, #eraserSizeValue {
  font-size: clamp(12px, 0.9vw, 16px);
  min-width: clamp(24px, 1.8vw, 32px);
  text-align: center;
}

/* 橡皮擦面板标题 */
.eraser-panel-title {
  font-size: 0.9vw;
  font-weight: bold;
  color: #333;
  margin-bottom: 1vw;
  text-align: center;
  padding-bottom: 0.5vw;
  border-bottom: 1px solid #eee;
}

/* 圈选擦除开关样式 */
.eraser-mode-switch {
  display: flex;
  align-items: center;
  margin-top: 0.5vw;
  justify-content: center;
  background-color: #f5f5f5;
  border-radius: 0.3vw;
  padding: 0.5vw 0.8vw;
  box-sizing: border-box;
  width: 100%;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    width: 100%;
    justify-content: center;
}

.checkbox-label input[type="checkbox"] {
    opacity: 0;
    position: absolute;
}

.checkbox-custom {
    position: relative;
    display: inline-block;
    width: 1vw;
    height: 1vw;
    background-color: white;
    border: 0.12vw solid #ccc;
    border-radius: 0.2vw;
    margin-right: 0.5vw;
    transition: all 0.2s ease;
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom {
    background-color: #2196F3;
    border-color: #2196F3;
}

.checkbox-custom::after {
    content: '';
    position: absolute;
    display: none;
    left: 30%;
    top: 10%;
    width: 30%;
    height: 60%;
    border: solid white;
    border-width: 0 0.12vw 0.12vw 0;
    transform: rotate(45deg);
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom::after {
    display: block;
}

.checkbox-label:hover .checkbox-custom {
    border-color: #999;
}

.checkbox-label input[type="checkbox"]:focus + .checkbox-custom {
    box-shadow: 0 0 0 0.15vw rgba(33, 150, 243, 0.3);
}

.switch-label {
    font-size: clamp(12px, 0.85vw, 16px);
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .eraser-mode-switch {
        padding: 1vw 1.2vw;
    }
    
    .checkbox-custom {
        width: 2.5vw;
        height: 2.5vw;
        margin-right: 1.2vw;
        border-width: 0.3vw;
    }
    
    .checkbox-custom::after {
        border-width: 0 0.3vw 0.3vw 0;
    }
    
    .slider-container {
        gap: 0.8vw;
        padding: 0.5vw 0;
    }
    
    #drawPanel input[type="range"], 
    #eraserPanel input[type="range"] {
        margin: 1.5vw 0;
    }
    
    .color-btn {
        width: 2.5vw;
        height: 2.5vw;
    }
    
    .color-btn.active::after {
        width: 1vw;
        height: 0.6vw;
        border-left: 0.25vw solid white;
        border-bottom: 0.25vw solid white;
    }
    
    .color-options {
        gap: 0.5vw;
        margin-bottom: 0.8vw;
    }
    
    .draw-panel {
        padding: 0.8vw;
        border-radius: 0.6vw;
    }
}

/* 为画布添加平滑过渡 */
#drawCanvas, #lassoTempCanvas {
    transition: width 0.1s ease, height 0.1s ease, left 0.1s ease, top 0.1s ease;
}

/* 为面板添加平滑过渡 */
.draw-panel {
    transition: opacity 0.2s ease;
}

/* 修改媒体查询的处理方式 */
@media screen and (max-width: 480px) {
    /* 在窄屏设备上强制工具栏为垂直布局 */
    #toolbar.horizontal {
        flex-direction: column;
        right: 5px;
        top: 50% !important;
        transform: translateY(-50%);
        padding: 8px 5px;
        left: auto !important; /* 确保不会受到其他定位的影响 */
    }

    /* 使用相对单位而不是固定像素 */
    #toolbar button,
    #dragArea,
    #pages {
        width: clamp(32px, 8vw, 40px);
        height: clamp(32px, 8vw, 40px);
    }

    #toolbar button svg,
    #dragArea svg {
        width: clamp(20px, 5vw, 24px);
        height: clamp(20px, 5vw, 24px);
    }

    #pages > span {
        font-size: clamp(12px, 3vw, 14px);
    }
}

/* 平板设备的媒体查询也使用相对单位 */
@media screen and (min-width: 481px) and (max-width: 768px) {
    #toolbar button,
    #dragArea,
    #pages {
        width: clamp(32px, 5vw, 36px);
        height: clamp(32px, 5vw, 36px);
    }
}

/* 菜单和面板样式 */
.menu-panel {
    position: absolute;
    background-color: white;
    border: 1px solid #ccc;
    border-radius: 0.5vw;
    box-shadow: 0 0 1vw rgba(0, 0, 0, 0.2);
    padding: 0.8vw;
    z-index: 1001;
    min-width: clamp(120px, 15vw, 300px);
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 0.6vw 1vw;
    cursor: pointer;
    border-radius: 0.3vw;
    font-size: clamp(12px, 1vw, 16px);
    transition: background-color 0.2s;
}

.menu-item:hover {
    background-color: #f0f0f0;
}

.menu-item svg {
    width: clamp(16px, 1.5vw, 24px);
    height: clamp(16px, 1.5vw, 24px);
    margin-right: 0.8vw;
}

.menu-item span {
    flex: 1;
    white-space: nowrap;
}

.menu-separator {
    height: 1px;
    background-color: #ddd;
    margin: 0.4vw 0;
}

/* 面板样式 */
.tool-panel {
    position: absolute;
    background-color: white;
    border: 1px solid #ccc;
    border-radius: 0.5vw;
    box-shadow: 0 0 1vw rgba(0, 0, 0, 0.2);
    padding: 1vw;
    z-index: 1001;
    min-width: clamp(200px, 20vw, 400px);
}

.panel-header {
    font-size: clamp(14px, 1.2vw, 18px);
    font-weight: bold;
    margin-bottom: 1vw;
    padding-bottom: 0.5vw;
    border-bottom: 1px solid #eee;
}

.panel-content {
    font-size: clamp(12px, 1vw, 16px);
}

.panel-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.8vw;
    margin-top: 1vw;
    padding-top: 0.8vw;
    border-top: 1px solid #eee;
}

.panel-button {
    padding: 0.4vw 1vw;
    border-radius: 0.3vw;
    font-size: clamp(12px, 0.9vw, 14px);
    cursor: pointer;
    border: 1px solid #ccc;
    background-color: white;
    transition: all 0.2s;
}

.panel-button:hover {
    background-color: #f0f0f0;
}

.panel-button.primary {
    background-color: #2253bd;
    color: white;
    border-color: #2253bd;
}

.panel-button.primary:hover {
    background-color: #1a408f;
    border-color: #1a408f;
}