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

html, body {
    margin: 0 !important;
    padding: 0 !important;
    width: 100%;
    overflow-x: hidden;
}

html {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #e3f2fd 0%, #ffffff 100%);
    min-height: 100vh;
    color: #333;
    margin-top: 0 !important;
    padding-top: 0 !important;
}

.navbar {
    background: #fff;
    padding: 15px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: flex-end;
    gap: 10px;/*30px*/
    padding: 0 20px;
}

.nav-item {
    color: #666;
    cursor: pointer;
    font-size: 14px;
    transition: color 0.3s;
}

.nav-item:hover {
    color: #1976d2;
}

.nav-item.active {
    color: #1976d2;
    font-weight: 500;
}

.nav-item.active-link {
    color: #1976d2;
}

.navbar a {
    text-decoration: none;
}

.navbar a:hover {
    text-decoration: none;
}

.aigc-auth-links {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 12px;
}
.aigc-auth-links .auth-link {
    color: #666;
    font-size: 14px;
    text-decoration: none;
}
.aigc-auth-links .auth-link:hover {
    color: #1976d2;
}
.aigc-auth-links .auth-link.primary {
    color: #1976d2;
    font-weight: 500;
}
.aigc-auth-links .auth-user {
    color: #666;
    font-size: 14px;
}

.container {
    max-width: 1200px;
    margin: 20px auto;/*40px auto;*/
    padding: 0 20px;
}
/* 当有 fixed header 时，第一个容器需要额外的 margin-top */
body.with-aigc-sidebar > .container:first-of-type,
body:not(.with-aigc-sidebar) > .container:first-of-type,
body.with-aigc-sidebar > .detect-container:first-of-type,
body:not(.with-aigc-sidebar) > .detect-container:first-of-type,
body.with-aigc-sidebar > .faq-container:first-of-type,
body:not(.with-aigc-sidebar) > .faq-container:first-of-type,
body.with-aigc-sidebar > [class*="container"]:first-of-type:not(.aigc-sidebar),
body:not(.with-aigc-sidebar) > [class*="container"]:first-of-type:not(header) {
    margin-top: 80px !important; /* header 高度 + 原有 margin */
}

/* 历史记录样式 */
.history-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.history-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.history-btn:active {
    transform: translateY(0);
}

.history-icon {
    font-size: 16px;
}

.history-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    display: none !important;
    flex-direction: column;
    overflow: hidden;
}

.history-panel.active {
    display: flex !important;
}

.history-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.history-panel-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.history-panel-actions {
    display: flex;
    gap: 10px;
}

.history-clear-btn,
.history-close-btn {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.3s;
}

.history-clear-btn:hover,
.history-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.history-close-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    font-size: 20px;
    line-height: 1;
}

.history-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.history-empty {
    text-align: center;
    padding: 60px 20px;
    color: #999;
    display: none;
}

.history-empty.active {
    display: block;
}

.history-empty p {
    font-size: 16px;
}

.history-item {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    border: 1px solid #e0e0e0;
    transition: all 0.3s;
}

.history-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    padding: 8px 0;
}

.history-item-header:hover {
    background: rgba(0, 0, 0, 0.02);
    margin: -8px -8px 4px -8px;
    padding: 8px;
    border-radius: 4px;
}

.history-item-time {
    font-size: 13px;
    color: #666;
    font-weight: 500;
}

.history-item-preview {
    color: #999;
    font-size: 12px;
    margin-top: 4px;
}

.history-item-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-shrink: 0;
}

.history-item-toggle,
.history-item-copy,
.history-item-delete {
    background: none;
    border: none;
    font-size: 14px;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 4px;
    transition: all 0.3s;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.history-item-toggle:hover {
    background: #e3f2fd;
    color: #1976d2;
}

.history-item-copy:hover {
    background: #e3f2fd;
}

.history-item-delete:hover {
    background: #ffebee;
}

.history-item-content {
    font-size: 14px;
    line-height: 1.6;
    color: #333;
    word-break: break-word;
    padding-top: 12px;
    margin-top: 8px;
    border-top: 1px solid #e0e0e0;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
    }
    to {
        opacity: 1;
        max-height: 2000px;
    }
}

.history-item.expanded .history-item-content {
    display: block;
}

.history-item-content pre {
    background: #f5f5f5;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 13px;
    margin: 0;
}

/* 历史记录遮罩层 */
.history-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
}

.history-overlay.active {
    display: block;
}

@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    
    .history-panel {
        width: 95%;
        max-height: 90vh;
    }
    
    .history-panel-header {
        padding: 15px;
    }
    
    .history-panel-body {
        padding: 15px;
    }
    
    .history-item {
        padding: 12px;
    }
}

/* ===== AIGC 左侧导航（新增） ===== */
body.with-aigc-sidebar {
    padding-left: 0;
}
.aigc-navbar-wrapper {
    width: 100%;
    max-width: 1400px;
    box-sizing: border-box;
}
.aigc-sidebar-toggle {
    position: fixed;
    top: 80px;
    left: 16px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: #1976d2;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 16px rgba(25,118,210,0.25);
    cursor: pointer;
    z-index: 1002;
    transition: background 0.2s ease, transform 0.2s ease, left 0.25s ease;
}
.aigc-sidebar-toggle i {
    font-size: 18px;
}
.aigc-sidebar-toggle:hover {
    transform: translateY(-2px);
    background: #115bb5;
}
.aigc-sidebar-toggle.is-open {
    background: #0d47a1;
}
.aigc-sidebar-toggle:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(25,118,210,0.25);
}
.aigc-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 90px;
    background: #ffffff;
    box-shadow: 2px 0 12px rgba(0,0,0,0.06);
    z-index: 1001; /* 高于头部导航栏，确保不被遮挡 */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center; /* 垂直居中 */
    padding-top: 0;
    padding-bottom: 0;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.aigc-sidebar .nav-item-icon {
    width: 65px;
    height: 50px;
    margin: 10px 0;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: #1976d2;
    background: #f5f9ff;
    cursor: pointer;
    transition: all .2s ease;
    text-decoration: none;
    font-size: 18px;
}
.aigc-sidebar .nav-item-icon .nav-item-label{
    font-size: 14px;/*10px*/
    line-height: 1.1;
    margin-top: 3px;
    color: #5d8bd6;
}
.aigc-sidebar .nav-item-icon:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(25,118,210,0.15);
}
.aigc-sidebar .nav-item-icon.active {
    background: #1976d2;
    color: #fff;
    box-shadow: 0 6px 16px rgba(25,118,210,0.25);
}
.aigc-sidebar .nav-item-icon.active .nav-item-label{
    color: #ffffff;
    opacity: 0.95;
}

body.with-aigc-sidebar.aigc-sidebar-open .aigc-sidebar {
    transform: translateX(0);
    pointer-events: auto;
}

body.with-aigc-sidebar:not(.aigc-sidebar-open) .aigc-sidebar {
    transform: translateX(-110%);
    box-shadow: none;
    pointer-events: none;
}

body.with-aigc-sidebar.aigc-sidebar-open .aigc-sidebar-toggle {
    left: 88px;
}
/* 桌面端头部导航优化 - 确保紧贴顶部，但不遮挡左侧导航 */
header#navbar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    margin-top: 0 !important;
    margin-left: 0;
    padding-top: 0 !important;
    margin-bottom: 0 !important;
    z-index: 1000; /* 低于左侧导航栏 */
    width: 100% !important;
}
/* 确保所有页面 body 都贴顶 */
html {
    margin-top: 0 !important;
    padding-top: 0 !important;
}
body {
    padding-top: 0 !important;
    margin-top: 0 !important;
}
/* 确保第一个子元素也贴顶 */
body > *:first-child {
    margin-top: 0 !important;
    padding-top: 0 !important;
}
/* 确保 sidebar 和 header 都贴顶 */
.aigc-sidebar,
header#navbar {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

/* 当左侧导航展开时，头部导航栏从右侧开始 */
body.with-aigc-sidebar.aigc-sidebar-open header#navbar {
    left: 72px !important; /* 左侧导航栏宽度 */
    width: calc(100% - 72px) !important;
}

/* 侧栏占位（避免内容被遮挡） */
body.with-aigc-sidebar.aigc-sidebar-open .container,
body.with-aigc-sidebar.aigc-sidebar-open .navbar .nav-container,
body.with-aigc-sidebar.aigc-sidebar-open header#navbar .container {
    padding-left: 80px;
}
body.with-aigc-sidebar:not(.aigc-sidebar-open) .container,
body.with-aigc-sidebar:not(.aigc-sidebar-open) .navbar .nav-container,
body.with-aigc-sidebar:not(.aigc-sidebar-open) header#navbar .container {
    padding-left: 0;
}
/* 内容区域需要 margin-top 来避免被 fixed header 遮挡（但 header 本身要贴顶） */
body.with-aigc-sidebar > div:not(.aigc-sidebar):not(header):not(.container):first-of-type {
    /*margin-top: 60px;*/ /* header 高度 */
}
body:not(.with-aigc-sidebar) > div:not(header):not(.container):first-of-type {
    margin-top: 60px; /* header 高度 */
}
@media (max-width: 768px) {
    body.with-aigc-sidebar .container,
    body.with-aigc-sidebar .navbar .nav-container,
    body.with-aigc-sidebar header#navbar .container {
        padding-left: 0;
    }
    .aigc-sidebar { 
        display: none; 
    }
    /* 移动端头部导航优化 - 恢复全宽，不设置 margin-left */
    body.with-aigc-sidebar header#navbar {
        margin-left: 0 !important;
        width: 100% !important;
        left: 0 !important; /* 移动端重置 left，避免被桌面端的 left: 72px 影响 */
        right: 0 !important;
    }
    header#navbar {
        position: sticky !important; /* 移动端使用 sticky 而不是 fixed */
        top: 0 !important;
        left: 0 !important; /* 确保移动端从左边开始 */
        right: 0 !important;
        margin-top: 0 !important;
        padding-top: 0 !important;
        z-index: 1000;
        min-height: 56px; /* 确保头部导航高度固定，方便移动端导航定位 */
        width: 100% !important;
    }
    header#navbar .container {
        padding-left: 12px !important;
        padding-right: 12px !important;
        padding-top: 8px !important;
        padding-bottom: 8px !important;
    }
    /* 移动端菜单样式优化 */
    header#navbar #mobile-menu {
        margin-top: 0 !important;
        margin-bottom: 0 !important;
        padding-top: 0 !important;
        top: 0;
        position: relative;
        border-top: none !important;
    }
    header#navbar #mobile-menu > div {
        padding-top: 0 !important;
        margin-top: 0 !important;
    }
    /* 移动端内容区域优化 */
    body.with-aigc-sidebar .container {
        padding: 10px 12px !important;
        margin: 0 auto;
    }
    .aigc-sidebar-toggle {
        display: none;
    }
}

/* ===== 移动端横向工具导航 ===== */
.aigc-mobile-nav{
    position: relative;
    background: #ffffff;
    border-bottom: 1px solid #eef0f4;
    padding: 8px 0;
    overflow: hidden;
    display: none; /* 默认桌面隐藏，移动端显示（见媒体查询） */
    z-index: 999;
}
.aigc-mobile-track{
    display: flex;
    gap: 8px;
    padding: 0 0 0 12px; /* 左侧 padding 确保第一个项目完全可见 */
    padding-right: 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.aigc-mobile-track::-webkit-scrollbar{ display: none; }
.aigc-mobile-item{
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 9999px;
    background: #f5f9ff;
    color: #1976d2;
    text-decoration: none;
    font-size: 13px;
    white-space: nowrap;
}
.aigc-mobile-item i{ font-size: 14px; }
.aigc-mobile-item.active{
    background: #1976d2;
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(25,118,210,0.2);
}
.aigc-mobile-fade-left,
.aigc-mobile-fade-right{
    position: absolute;
    top: 0;
    bottom: 0;
    width: 24px;
    pointer-events: none;
}
.aigc-mobile-fade-left{
    left: 0;
    background: linear-gradient(to right, #fff, rgba(255,255,255,0));
    display: none; /* 隐藏左侧渐变，避免遮挡内容 */
}
.aigc-mobile-fade-right{
    right: 0;
    background: linear-gradient(to left, #fff, rgba(255,255,255,0));
}
@media (max-width: 768px){
    .aigc-mobile-nav{ 
        display: block !important; 
        position: sticky;
        top: 56px; /* 头部导航高度（与上面min-height一致） */
        z-index: 999;
        background: #ffffff;
    }
    /* 确保移动端导航在头部导航下方 */
    header#navbar + .aigc-mobile-nav {
        margin-top: 0;
    }
    /* 移动端导航滚动优化 */
    .aigc-mobile-track {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
        padding-left: 12px !important; /* 确保左侧有足够空间 */
    }
    /* 确保第一个导航项完全可见 */
    .aigc-mobile-item:first-child {
        margin-left: 0;
    }
}
