:root {
    /* 颜色变量 */
    --bg-color: #1a1a1a;
    --text-color: #f0f0f0;
    --text-secondary: #c6cccc;
    --hover-color: #a0a0a0;
    --favorite-color: #ff4d4d;
    --overlay-dark: rgba(0, 0, 0, 0.5);
    --overlay-light: rgba(255, 255, 255, 0.1);
	
  --white: #fff;
  --radius-md: 8px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.15);
    
    /* 尺寸变量 */
    --nav-btn-size: 50px;
    --toolbar-gap: 12px;
    --detail-padding: 20px 25px;
    
    /* 动效变量 */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease-out;
    --transition-slow: 0.5s cubic-bezier(0.2, 0.8, 0.4, 1);
    --image-transition: 0.6s cubic-bezier(0.22, 1, 0.36, 1);
    --blur-transition: 0.8s cubic-bezier(0.32, 0, 0.67, 0);
}

/* 基础重置 */
body, html {
    height: 100%;
    margin: 0;
    overflow: hidden;
    background-color: var(--bg-color);
    font-family: 'Source Sans Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* ======================
   图片容器系统
   ====================== */
.bgimg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    opacity: 1;
    z-index: 1;
    
    /* 优化属性 */
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
    
    /* 过渡效果优化 - 只对opacity应用过渡 */
    transition: opacity 0.3s ease;
}

/* 修改加载状态 - 只模糊图片不模糊文字 */
.bgimg.is-loading {
    opacity: 0.98;
}

/* 图片模糊效果容器 */
.bgimg::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: inherit;
    background-size: cover;
    background-position: center;
    z-index: -1;
    transition: filter var(--blur-transition);
    will-change: filter;
}

.bgimg.is-loading::before {
    filter: blur(15px) brightness(0.9);
}

/* ======================
   加载指示器
   ====================== */
/* ======================
   加载动画系统
   ====================== */
.loading-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none; /* 初始隐藏 */
    flex-direction: column;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.loading-indicator.visible {
    display: flex; /* 先确保元素显示 */
}

.loading-indicator.active {
    opacity: 1;
}

.spinner {
    width: 56px;
    height: 56px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--text-color);
    border-radius: 50%;
    animation: spin 1.2s cubic-bezier(0.5, 0.1, 0.4, 0.9) infinite;
    margin-bottom: 16px;
    will-change: transform;
}

.loading-text {
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.5px;
    animation: fadePulse 2s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes fadePulse {
    0%, 100% { opacity: 0.8; transform: scale(0.98); }
    50% { opacity: 1; transform: scale(1.02); }
}

/* ======================
   元信息区域
   ====================== */
.w3-detail {
    position: fixed;
    left: 0;
    bottom: 0;
    width: 100%;
    padding: var(--detail-padding);
    color: var(--text-color);
    background: linear-gradient(to top, var(--overlay-dark), transparent);
    backdrop-filter: blur(20px);
    z-index: 10;
    transform: translateY(0);
    transition: transform var(--transition-slow), backdrop-filter var(--transition-fast);
}

.w3-detail.collapsed {
    transform: translateY(calc(100% - 60px));
    backdrop-filter: blur(5px);
}

.detail-header {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.w3-detail .w3-large {
    font-size: 1.2rem;
    padding-bottom: 8px;
    text-align: left;
    margin: 0;
}

.w3-detail .w3-detail-large {
    color: #c6cccc;
    text-indent: 2em;
    line-height: 1.4;
}

.w3-detail .w3-detail-large p {
    margin: 0 0 5px 0;
    padding: 0;
}

/* 新增样式 */
.title-toggle {
    background: none;
    border: none;
    color: inherit;
    padding: 0;
    margin: 0;
    text-align: left;
    flex-grow: 1;
    cursor: pointer;
}

.title-toggle:focus {
    outline: none;
}

.detail-header {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.toggle-detail {
    background: none;
    border: none;
    color: var(--text-color);
    margin-top: -3;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    line-height: 0; /* 消除按钮内部间距 */
}

.toggle-icon {
    transition: transform 0.3s ease;
    vertical-align: middle;
}

/* 收起状态 */
.w3-detail.collapsed .w3-detail-large {
    display: none;
}

.w3-detail.collapsed .toggle-icon {
    transform: rotate(-180deg);
}

/* 无障碍提示 */
[aria-expanded="false"] + .w3-detail-large {
    visibility: hidden;
}

/* ======================
   工具栏与按钮
   ====================== */
.toolbar-container {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    gap: var(--toolbar-gap);
    z-index: 20;
}

.download-links {
    display: flex;
    align-items: center;
    background-color: var(--overlay-dark);
    border-radius: 24px;
    padding: 8px 16px;
    backdrop-filter: blur(10px);
}

.download-link {
    color: var(--text-color);
    text-decoration: none;
    font-size: 14px;
    padding: 0 6px;
    transition: color var(--transition-fast);
}

.download-link:hover {
    color: var(--hover-color);
}

.official-link {
    display: flex;
    align-items: center;
    gap: 6px;
    background-color: var(--overlay-dark);
    border-radius: 24px;
    padding: 8px 16px;
    color: var(--text-color);
    text-decoration: none;
    font-size: 14px;
    transition: all var(--transition-fast);
    backdrop-filter: blur(10px);
}

.official-link:hover {
    color: var(--hover-color);
}

/* 修正图标显示的核心样式 */
.official-icon {
    display: inline-block;
    width: 18px; 
    height: 18px;
    vertical-align: middle;
    fill: currentColor; /* 继承父元素颜色 */
    overflow: visible; /* 确保边缘不裁剪 */
}

/* 悬停状态优化 */
.official-link:hover .official-icon {
    transform: scale(1.1);
}

.official-text {
    white-space: nowrap;
}

.toolbar-container {
    gap: var(--toolbar-gap);
}

.bg-save-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background-color: var(--overlay-dark);
    border: none;
    border-radius: 24px;
    padding: 8px 16px;
    color: var(--text-color);
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition-fast);
    backdrop-filter: blur(10px);
}

.bg-save-btn.favorited {
    color: var(--favorite-color);
}

/* ======================
   导航按钮
   ====================== */
.nav-btn {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: var(--nav-btn-size);
    height: var(--nav-btn-size);
    border-radius: 50%;
    background-color: var(--overlay-dark);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 20;
    transition: all var(--transition-fast);
    backdrop-filter: blur(5px);
}

.nav-btn:hover {
    background-color: var(--overlay-dark);
    transform: translateY(-50%) scale(1.1);
}

/* 禁用状态的按钮样式 */
.nav-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* 无障碍焦点样式 */
.nav-btn:not(.disabled):focus {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

#prev-btn {
    left: 20px;
}

#next-btn {
    right: 20px;
}

/* ===== 增强版Toast通知 ===== */
.toast-container {
  position: fixed;
  bottom: 40px;
  left: 0;
  right: 0;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 0 20px;
  pointer-events: none;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  background-color: var(--white);
  display: inline-flex;
  align-items: center;
  gap: 12px;
  transform: translateY(20px);
  opacity: 0;
  transition: var(--transition);
  max-width: 100%;
  width: auto;
  min-width: 200px;
  pointer-events: auto;
  word-break: break-word;
  text-align: left;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.toast-success .toast-icon {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z'/%3E%3C/svg%3E");
}

.toast-error .toast-icon {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12 17 15.59z'/%3E%3C/svg%3E");
}

.toast-warning .toast-icon {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M12 5.99L19.53 19H4.47L12 5.99M12 2L1 21h22L12 2zm1 14h-2v2h2v-2zm0-6h-2v4h2v-4z'/%3E%3C/svg%3E");
}

.toast-info .toast-icon {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z'/%3E%3C/svg%3E");
}

.toast-success {
  background-color: rgba(76, 175, 80, 0.9);
  color: white;
}

.toast-error {
  background-color: rgba(244, 67, 54, 0.9);
  color: white;
}

.toast-warning {
  background-color: rgba(255, 165, 2, 0.9);
  color: white;
}

.toast-info {
  background-color: rgba(33, 150, 243, 0.9);
  color: white;
}

.toast-message {
  flex: 1;
  font-size: 0.9375rem;
  line-height: 1.4;
  min-width: 0; /* 允许文本换行 */
}

.toast-close {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0;
  margin-left: 8px;
  opacity: 0.7;
  flex-shrink: 0;
  line-height: 1;
  transition: var(--transition-fast);
}

.toast-close:hover {
  opacity: 1;
}

/* 响应式调整 */
@media (max-width: 480px) {
  .toast {
    width: calc(100% - 40px);
    padding: 10px 16px;
  }
  
  .toast-message {
    font-size: 0.875rem;
  }
}

/* 重试按钮 */
/* 添加缓存错误状态 */
.bgimg.cache-error {
    filter: blur(5px) brightness(0.7);
}

/* 优化重试按钮 */
.retry-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 12px 24px;
    background: linear-gradient(to right, #ff5f6d, #ff9966);
    color: white;
    font-weight: bold;
    box-shadow: 0 2px 10px rgba(255, 99, 71, 0.3);
    border: none;
    border-radius: 24px;
    font-size: 16px;
    cursor: pointer;
    z-index: 1001;
}

.retry-btn:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* ======================
   响应式设计
   ====================== */
@media (max-width: 768px) {
    :root {
        --image-transition: 0.4s ease-out;
        --nav-btn-size: 44px;
        --toolbar-gap: 8px;
        --detail-padding: 15px 20px;
    }
    
    .bgimg::before {
        filter: none; 
    }
	
    .spinner {
        width: 36px;
        height: 36px;
        border-width: 2px;
    }
    .loading-text {
        font-size: 12px;
    }

    .official-text {
        display: none;
    }
    
    .official-link {
        padding: 8px 12px;
    }
	
    .official-icon {
        margin-right: 0;
        width: 20px;
        height: 20px;
    }
	
    .w3-detail .w3-detail-large,
    .w3-padding-kbd,
    .save-text {
        display: none;
    }

    .w3-detail .w3-large {
        font-size: 1rem;
    }

    .toolbar-container {
        top: 15px;
        right: 15px;
    }

    .w3-detail.collapsed {
        transform: translateY(calc(100% - 50px));
    }

    .toast {
        bottom: 20px;
        top: auto;
        transform: translateX(-50%);
        width: 90%;
        max-width: none;
    }
    
    .toast.fade-out {
        transform: translateX(-50%) scale(0.95);
    }
    
    .loading-indicator {
        transform: scale(0.9);
    }
}

/* 减少动画设置 */
@media (prefers-reduced-motion: reduce) {
    :root {
    --transition-fast: 0.01s;
        --transition-normal: 0.01s;
        --transition-slow: 0.01s;
        --image-transition: 0.01s;
        --blur-transition: 0.01s;
    }
    
    .bgimg,
    .bgimg::before {
        transition: none !important;
    }
    .spinner {
        animation: spin 4s linear infinite;
    }
    .loading-text {
        animation: none;
    }
	
    .toast {
        transition: none; /* 保留原有类名 */
    }
}