/* 主要样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #ffffff;
    min-height: 100vh;
    color: #333;
    overflow-x: hidden;
}

body.modal-open {
    overflow: hidden;
}

/* 主要内容 */
.main-content {
    margin-top: 80px;
    padding: 2rem;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

.welcome-card {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.welcome-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: #000000;
}

.info-icon {
    min-width: 24px;
    width: 24px;
    height: 24px;
    flex-shrink: 0; /* 防止图标缩小 */
    background: #1976d2;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 14px;
}

/* 自定义提示框 */
.custom-tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.2s ease;
    max-width: 300px;
    width: auto;
    text-align: left;
    white-space: normal;
    word-wrap: break-word;
    word-break: break-word;
    line-height: 1.4;
}

.custom-tooltip.show {
    opacity: 1;
}

/* 删除所有箭头样式 */

/* 响应式设计 */
@media (max-width: 768px) {
    .main-content {
        padding: 1rem;
        margin-top: 90px;
    }
    
    .welcome-card {
        padding: 1.2rem;
    }
}

/* 特别针对中等宽度设备 */
@media (min-width: 501px) and (max-width: 650px) {
    .main-content {
        margin-top: 100px;
    }
}

/* 动画关键帧 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
    }
    to {
        transform: translateX(100%);
    }
}

@keyframes scaleIn {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes scaleOut {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        opacity: 0;
        transform: scale(0.8);
    }
}

/* 数字滚动效果 */
.number-animation {
    display: inline-block;
    color: #4285f4;
    font-weight: bold;
}

/* 右侧浮动工具栏 */
.right-toolbar {
    position: fixed;
    top: 50%;
    right: 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px; /* 缩小按钮之间的间距 */
    z-index: 1200;
    padding: 6px 6px; /* 缩小上下两头的边距 */
    background: rgba(255, 255, 255, 0.6);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    backdrop-filter: blur(16px) saturate(180%);
    border-radius: 40px; /* 增大外部圆角弧度，避免视觉上比内圆更窄 */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12), inset 0 0 0 1px rgba(255,255,255,0.4);
    transform: translateY(-50%);
    /* 统一按钮与间距变量，供指示器计算使用 */
    --rt-btn: 44px;
    --rt-gap: 10px;
    --rt-pad: 6px;
}

.rt-item {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    outline: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    color: #1f2937;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(0,0,0,0.08);
    transition: transform 0.15s ease, box-shadow 0.2s ease, background-color 0.2s ease, color 0.2s ease, filter 0.12s ease;
}

/* 两态切换的蓝色指示动画（在两个按钮之间移动/缩放） */
.rt-switch-indicator {
    position: absolute;
    left: 50%;
    top: var(--rt-pad);
    width: var(--rt-btn);
    height: var(--rt-btn);
    border-radius: 50%;
    background: linear-gradient(180deg, #09c2df 0%, #09b2e0 100%);
    box-shadow: 0 10px 26px rgba(9,178,224,0.45);
    z-index: 1; /* 位于按钮下层，避免遮挡图标 */
    opacity: 0; /* 仅切换时显示 */
    transform: translateX(-50%);
    transition: top 420ms cubic-bezier(.22,1,.36,1), opacity 160ms ease;
    pointer-events: none;
}

.right-toolbar.switching .rt-switch-indicator { opacity: 1; }
.right-toolbar .rt-item { position: relative; z-index: 0; }
.right-toolbar .rt-item .rt-icon,
.right-toolbar .rt-item svg { position: relative; z-index: 3; }

/* 主区域上移淡出，用于页面切换，不再被覆盖显示 */
body.rt-main-out .main-content,
body.rt-main-out .footer {
    transform: translateY(-40px);
    opacity: 0;
    transition: transform 300ms cubic-bezier(.22,1,.36,1), opacity 220ms ease;
}

.rt-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(0,0,0,0.12);
    background-color: rgba(9, 178, 224, 0.12);
    color: #09b2e0;
}

.rt-item:active {
    transform: translateY(0);
    background-color: rgba(9, 178, 224, 0.2); /* 点击时颜色更深 */
    color: #0994c0;
}

.rt-item.active {
    background: linear-gradient(180deg, #09c2df 0%, #09b2e0 100%);
    color: white;
    box-shadow: 0 12px 28px rgba(9, 178, 224, 0.35);
}

/* 防止动画过程中 hover/active 状态误触发颜色变化 */
.right-toolbar.switching #rtHomeBtn,
.right-toolbar.switching #rtSearchBtn {
    background: #ffffff !important;
    color: #1f2937 !important;
    box-shadow: 0 6px 16px rgba(0,0,0,0.08) !important;
}

/* 选中按钮在悬停/按下时有更明显的深浅变化 */
.rt-item.active:hover {
    filter: brightness(1.06);
}
.rt-item.active:active {
    filter: brightness(0.92);
}

.rt-icon {
    width: 22px;
    height: 22px;
}

/* 让图标在两种主题下观感更柔和，并区分 <img> 与 <svg> 的处理 */
.right-toolbar .rt-item .rt-icon { opacity: 0.8; transition: opacity 160ms ease, filter 160ms ease; }
.right-toolbar .rt-item:hover .rt-icon { opacity: 0.92; }
.right-toolbar .rt-item:active .rt-icon { opacity: 1; }

/* 深色主题下，仅对位图图标(<img>)做反色增亮，避免影响 SVG */
html.theme-dark .right-toolbar .rt-item img.rt-icon {
    filter: invert(1) brightness(0.96) saturate(0.75);
}
html.theme-dark .right-toolbar .rt-item:hover img.rt-icon { filter: invert(1) brightness(1) saturate(0.9); }
html.theme-dark .right-toolbar .rt-item:active img.rt-icon { filter: invert(1) brightness(1.06) saturate(1); }

/* 确保 SVG 图标跟随按钮文字颜色渲染（避免被错误滤镜影响） */
.right-toolbar .rt-item svg { color: inherit; }
.right-toolbar .rt-item svg path, 
.right-toolbar .rt-item svg circle, 
.right-toolbar .rt-item svg line, 
.right-toolbar .rt-item svg polyline { stroke: currentColor; }

/* 移除旧的右侧悬浮搜索面板相关样式（已废弃） */

/* 全屏搜索页（滑入下一页） */
.rt-search-page {
    position: fixed;
    left: 0;
    right: 0; /* 与主页相同宽度，不做避让 */
    top: 80px;   /* 与主页内容起始位置一致 */
    bottom: 0;
    background: transparent;
    z-index: 950; /* 低于导航栏(1000)与右侧边栏(1200) */
    pointer-events: none; /* 默认不拦截事件，打开后启用 */
}
html.theme-dark .rt-search-page { background: transparent; }

/* 当导航栏收起时，搜索页顶边与视口贴齐，避免分层缝隙 */
#navbar.hidden ~ #app-main .rt-search-page { top: 0; }
#navbar.hidden ~ #app-main .rt-search-page .rtsp-sheet { border-radius: 0; }

.rtsp-inner {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 32px 16px 24px;
}

.rtsp-input-wrap {
    width: min(880px, 92vw);
    transform: translateY(calc(50vh - 27px)); /* 居中 */
    transition: transform 360ms cubic-bezier(.22,1,.36,1), opacity 200ms ease;
    opacity: 1; /* 默认显示输入框 */
}
.rt-sp-search {
    width: 100%;
    height: 54px;
    border-radius: 28px;
    border: 1px solid rgba(0,0,0,0.08);
    background: #fff;
    color: #111827;
    font-size: 16px;
    padding: 0 18px;
    outline: none;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
}
html.theme-dark .rt-sp-search { background: #171a20; color: #e8e8e8; border-color: rgba(255,255,255,0.08); }

.rtsp-results-card {
    width: min(1100px, 94vw);
    margin-top: 28px;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 22px;
    box-shadow: 0 14px 50px rgba(0,0,0,0.12);
    transform: translateY(60px);
    transition: transform 360ms cubic-bezier(.22,1,.36,1), opacity 200ms ease;
    opacity: 0;
    padding: 18px 18px 22px;
}
html.theme-dark .rtsp-results-card { background: rgba(22,24,28,0.92); border-color: rgba(255,255,255,0.06); box-shadow: 0 20px 60px rgba(0,0,0,0.6); }

.rt-search-page.open { pointer-events: auto; }
.rt-search-page.has-query .rtsp-input-wrap { transform: translateY(0); opacity: 1; }
.rt-search-page.has-query .rtsp-results-card { transform: translateY(0); opacity: 1; }

/* 升起底板 */
.rtsp-sheet {
    position: absolute;
    left: 0; right: 0; bottom: 0; top: 0;
    background: #f5f7fb; /* 与主页背景保持一致 */
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -10px 30px rgba(0,0,0,0.08);
    transform: translateY(100%);
    transition: transform 360ms cubic-bezier(.22,1,.36,1);
}
.rt-search-page.open .rtsp-sheet { transform: translateY(0); }
html.theme-dark .rtsp-sheet { background: #0f1115; }

.rtsp-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}
@media (max-width: 1280px) { .rtsp-grid { grid-template-columns: repeat(3, 1fr);} }
@media (max-width: 920px) { .rtsp-grid { grid-template-columns: repeat(2, 1fr);} }
@media (max-width: 560px) { .rtsp-grid { grid-template-columns: 1fr;} }

.rtsp-card {
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 14px;
    background: #fff;
    cursor: pointer;
    transition: transform 200ms ease, box-shadow 140ms ease, border-color 140ms ease, opacity 200ms ease;
}
.rtsp-card:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(0,0,0,0.12); border-color: #d5d5d5; }
.rtsp-title { font-weight: 700; color: #111827; font-size: 15px; margin-bottom: 6px; }
.rtsp-desc { color: #6b7280; font-size: 13px; line-height: 1.45; height: 2.9em; overflow: hidden; }

html.theme-dark .rtsp-card { background: #171a20; border-color: rgba(255,255,255,0.06); }
html.theme-dark .rtsp-card:hover { box-shadow: 0 12px 28px rgba(0,0,0,0.55); border-color: rgba(255,255,255,0.12); }
html.theme-dark .rtsp-title { color: #e8e8e8; }
html.theme-dark .rtsp-desc { color: #aab4bf; }

/* 移除卡片时的淡出状态 */
.rtsp-card.rtsp-removing { opacity: 0; }

/* 黑白模式（整个页面灰度） */
body.grayscale-mode {
    filter: grayscale(1);
}

/* 主题模式：暗色与浅色 */
:root {
    color-scheme: light dark;
}

/* 跟随系统默认由浏览器处理；当强制主题时设置根变量 */
html.theme-light {
    color-scheme: light;
}
html.theme-dark {
    color-scheme: dark;
}

.rt-divider {
    width: 22px;
    height: 4px;
    border-radius: 10px;
    background: rgba(0,0,0,0.08);
}

/* 右侧工具栏悬浮标签（显示在工具栏左侧，白色卡片） */
.rt-label {
    position: fixed;
    left: 0; /* 将由脚本计算具体位置 */
    top: 0;  /* 将由脚本计算具体位置 */
    transform: translateX(8px);
    opacity: 0;
    pointer-events: none;
    background: #fff;
    color: #111827;
    border-radius: 12px;
    padding: 8px 12px;
    font-size: 13px;
    line-height: 1.2;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12), inset 0 1px 0 rgba(255,255,255,0.6);
    border: 1px solid rgba(0,0,0,0.06);
    transition: opacity 0.16s ease, transform 0.2s ease;
    z-index: 1300;
    white-space: nowrap;
}

.rt-label.show {
    opacity: 1;
    transform: translateX(0);
}

/* 暗色主题下的右侧悬停卡片 */
html.theme-dark .rt-label {
    background: rgba(30,33,39,0.94);
    color: #e8e8e8;
    border-color: rgba(255,255,255,0.08);
    box-shadow: 0 10px 28px rgba(0,0,0,0.6);
}

/* 主题切换过渡：全屏圆形幕布与骨架屏 */
.theme-transition-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1100; /* 低于右侧工具栏(1200)，动画时不遮盖工具栏 */
    opacity: 0;
    transition: opacity 0.2s ease;
}

.theme-transition-overlay .mask-circle {
    position: absolute;
    left: var(--cx, 50%);
    top: var(--cy, 50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0.001);
    transform-origin: center;
    will-change: transform, opacity;
}

/* 使用超大阴影制造“外部幕布”，保持中心为透明圆孔 */
/* 黑夜目标：外部黑幕收拢到按钮（中心为孔） */
.theme-transition-overlay.to-dark .mask-circle { background: transparent; box-shadow: 0 0 0 200vmax rgba(0,0,0,1); }
/* 白天目标：白色从按钮向外扩张（实体圆扩张，无外部幕布） */
.theme-transition-overlay.to-light .mask-circle { background: #ffffff; box-shadow: none; }

.theme-transitioning {
    cursor: progress !important;
}

.theme-transitioning .skeletonize {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
}

.theme-transitioning .skeletonize > * { visibility: hidden; }
.theme-transitioning .skeletonize::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(0,0,0,0.06), rgba(0,0,0,0.08), rgba(0,0,0,0.06));
    animation: skeleton-shimmer 1.1s infinite linear;
    opacity: 0.9; /* 提升存在感，滚动后也清晰可见 */
}

@keyframes skeleton-shimmer {
    0% { background-position: -200px 0; }
    100% { background-position: calc(200px + 100%) 0; }
}

/* 基础暗色主题覆盖（最小可用） */
html.theme-dark body {
    background: #0f1115;
    color: #e8e8e8;
}
html.theme-dark .welcome-info { color: #e8e8e8; }
html.theme-dark .welcome-card {
    background: rgba(22, 24, 28, 0.85);
    border-color: rgba(255,255,255,0.06);
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
html.theme-dark .chart-title,
html.theme-dark .api-list h2 { color: #e8e8e8; }
html.theme-dark .right-toolbar {
    background: rgba(24, 26, 31, 0.55);
    box-shadow: 0 10px 30px rgba(0,0,0,0.45), inset 0 0 0 1px rgba(255,255,255,0.06);
}
html.theme-dark .rt-item { background: rgba(255,255,255,0.06); color: #e6f6ff; }
html.theme-dark .rt-item:hover { background-color: rgba(9, 178, 224, 0.18); color: #66d8f2; }
html.theme-dark .rt-item:active { background-color: rgba(9, 178, 224, 0.28); color: #9ae8ff; }

/* 小屏幕上靠内侧一点，避免与系统手势冲突 */
@media (max-width: 768px) {
    .right-toolbar { display: none; border-radius: 44px; }
}