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

/* 编辑器内容区域使用 Fira Code 字体 */
.header,
.main-container,
.status-bar,
.modal,
#components-panel,
#canvas-container {
    font-family: 'Fira Code', monospace;
}

/* 默认深色主题配色 - 与站点主题统一 */
:root {
    --bg: #0d1117;
    --panel: #161b22;
    --accent: #3498db;
    --tile: #1d232a;
    --text: #c9d1d9;
    --grid-line: #30363d;
    --border: #30363d;
    --button-bg: #21262d;
    --button-hover: #30363d;
    --zoom-controls-bg: rgba(22, 27, 34, 0.95);
    --header-bg: rgba(13, 17, 23, 0.95);
    --status-bg: rgba(13, 17, 23, 0.95);
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --card-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    --canvas-bg: #161b22;
}

/* 亮色主题 */
body.theme-light {
    --bg: #f7f9fc;
    --panel: #ffffff;
    --accent: #e74c3c;
    --tile: #eef2f7;
    --text: #2d3748;
    --grid-line: rgb(183, 170, 170);
    --border: #c1cbd6;
    --button-bg: #eef2f7;
    --button-hover: #e1e8f0;
    --zoom-controls-bg: rgba(255, 255, 255, 0.95);
    --header-bg: rgba(247, 249, 252, 0.95);
    --status-bg: rgba(247, 249, 252, 0.95);
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --card-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    --canvas-bg: #f7f9fc;
}

body {
    background: transparent;
    color: var(--text);
    transition: all 0.6s ease;
}

/* 只对画布区域应用像素化渲染 */
#canvas,
#canvas *,
.component-item img {
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

.header {
    display: none; /* 已删除标题栏 */
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo h1 {
    font-size: 1.6rem;
    color: var(--accent);
    font-weight: 600;
    transition: all 0.6s ease;
}

.controls {
    display: none; /* 已移至侧边栏 */
}

.btn {
    background: var(--button-bg);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 10px 18px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--card-shadow);
    font-size: 0.95rem;
}

.btn:hover {
    background: var(--button-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
    border-color: var(--accent);
}

.btn i {
    font-size: 1rem;
    width: 18px;
    text-align: center;
}

.main-container {
    display: flex;
    flex: 1;
    overflow: visible;
    padding: 0;
    gap: 0;
    min-height: 0;
}

/* 右侧组件面板 */
#components-panel {
    width: 280px;
    background: var(--panel);
    padding: 20px;
    border-left: 1px solid var(--border);
    box-shadow: var(--card-shadow);
    transition: all 0.6s ease;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.panel-header h2 {
    font-size: 1.3rem;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.6s ease;
}

.search-container {
    position: relative;
    margin-bottom: 20px;
    flex-shrink: 0;
}

#component-search {
    width: 100%;
    padding: 12px 16px 12px 40px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--tile);
    color: var(--text);
    font-size: 0.95rem;
    transition: all 0.6s ease;
    box-shadow: var(--card-shadow);
}

#component-search:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.2);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text);
    opacity: 0.6;
}

.search-hint {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.85rem;
    color: #888;
    background: rgba(0,0,0,0.05);
    padding: 2px 8px;
    border-radius: 4px;
    display: none;
}

/* 分页控制 */
.pagination-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    padding: 8px 12px;
    background: var(--tile);
    border-radius: 8px;
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.pagination-btn {
    background: var(--button-bg);
    color: var(--text);
    border: 1px solid var(--border);
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.pagination-btn:hover:not(:disabled) {
    background: var(--button-hover);
    border-color: var(--accent);
    transform: translateY(-1px);
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination-info {
    font-size: 0.9rem;
    color: var(--text);
    font-weight: 500;
}

#component-search:focus + .search-hint {
    display: block;
}

.category {
    margin-bottom: 25px;
    transition: all 0.6s ease;
}

/* 分类标题行 - 包含标题和内部分页 */
.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.category h3 {
    color: var(--accent);
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    transition: all 0.6s ease;
}

.category h3 i {
    font-size: 1rem;
}

/* 分类内部分页控制 */
.category-pagination {
    display: flex;
    align-items: center;
    gap: 8px;
}

.category-page-btn {
    background: var(--button-bg);
    color: var(--text);
    border: 1px solid var(--border);
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    padding: 0;
}

.category-page-btn:hover:not(:disabled) {
    background: var(--button-hover);
    border-color: var(--accent);
}

.category-page-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.category-page-info {
    font-size: 0.85rem;
    color: var(--text);
    min-width: 35px;
    text-align: center;
}

.components-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}

.component {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: var(--panel);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: var(--card-shadow);
}

.component:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    border-color: var(--accent);
}

.component.selected {
    border: 2px solid var(--accent);
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.3);
    background: rgba(231, 76, 60, 0.1);
}

.component img {
    width: 30px;
    height: 30px;
    object-fit: contain;
}

/* 中间画布区域 */
#canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: var(--canvas-bg);
    box-shadow: var(--card-shadow);
    transition: all 0.6s ease;
    min-width: 0;
}

#canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: default;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

body.theme-dark .grid-overlay {
    background-image:
        linear-gradient(rgba(90, 100, 120, 0.3) 1px, transparent 1px),
        linear-gradient(90deg, rgba(90, 100, 120, 0.3) 1px, transparent 1px);
}

/* 状态栏 */
.status-bar {
    background: var(--status-bg);
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    border-top: 1px solid var(--border);
    font-size: 0.9rem;
    transition: all 0.6s ease;
    backdrop-filter: blur(6px);
    box-shadow: 0 -3px 10px rgba(0, 0, 0, 0.05);
}

.status-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border);
    box-shadow: var(--card-shadow);
    transition: all 0.3s ease;
}

.status-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
}

.status-item i {
    color: var(--accent);
    font-size: 0.9rem;
    transition: all 0.6s ease;
}

/* 缩放控制按钮 */
.zoom-controls {
    display: flex;
    gap: 6px;
    background: var(--zoom-controls-bg);
    padding: 6px 10px;
    border-radius: 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    transition: all 0.6s ease;
    backdrop-filter: blur(6px);
    position: absolute;
    bottom: 20px;
    right: 20px;
    z-index: 10;
}

.zoom-btn {
    background: var(--button-bg);
    color: var(--text);
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: var(--card-shadow);
    font-size: 0.8rem;
}

.zoom-btn:hover {
    background: var(--accent);
    color: white;
    transform: scale(1.1);
}

/* 滚动条美化 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(225, 232, 240, 0.3);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 4px;
    transition: background 0.6s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: #c0392b;
}

/* 响应式调整 */
@media (max-width: 900px) {
    .main-container {
        flex-direction: column;
    }
   
    #components-panel {
        width: 100%;
        max-height: 250px;
    }
   
    .components-grid {
        grid-template-columns: repeat(10, 1fr);
    }
}

/* 移动端布局优化 */
@media (max-width: 768px) {
    /* 主容器布局 */
    .main-container {
        flex-direction: column;
        position: relative;
    }
    
    /* 左侧侧边栏改为悬浮抽屉 */
    #sidebar-nav {
        position: fixed;
        left: -200px;
        top: 70px;
        bottom: 0;
        width: 200px;
        z-index: 100;
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
        overflow-y: auto;
    }
    
    #sidebar-nav.show {
        left: 0;
    }
    
    /* 侧边栏展开按钮 */
    .sidebar-toggle {
        position: fixed;
        left: 10px;
        top: 80px;
        z-index: 99;
        width: 40px;
        height: 40px;
        background: var(--accent);
        color: white;
        border: none;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
        transition: all 0.3s ease;
    }
    
    .sidebar-toggle:active {
        transform: scale(0.95);
    }
    
    .sidebar-toggle i {
        font-size: 18px;
    }
    
    /* 遮罩层 */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 99;
        display: none;
        opacity: 0;
        transition: opacity 0.3s ease;
    }
    
    .sidebar-overlay.show {
        display: block;
        opacity: 1;
    }
    
    /* 画布容器占据主要空间 */
    #canvas-container {
        flex: 1;
        min-height: 400px;
        order: 1;
    }
    
    /* 组件面板移到底部 */
    #components-panel {
        width: 100%;
        max-height: 45vh;
        order: 2;
        border-left: none;
        border-top: 1px solid var(--border);
        padding: 15px;
        overflow-y: auto;
    }
    
    .panel-header h2 {
        font-size: 1.1rem;
    }
    
    .components-grid {
        grid-template-columns: repeat(8, 1fr);
        gap: 8px;
    }
    
    .component {
        width: 40px;
        height: 40px;
    }
    
    .component img {
        width: 32px;
        height: 32px;
    }
    
    /* 状态栏优化 */
    .status-bar {
        padding: 8px 10px;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 8px;
        order: 3;
        /* 隐藏滚动条但保持滚动功能 */
        scrollbar-width: none; /* Firefox */
        -ms-overflow-style: none; /* IE/Edge */
    }
    
    .status-bar::-webkit-scrollbar {
        display: none; /* Chrome/Safari/Opera */
    }
    
    .status-item {
        padding: 6px 10px;
        font-size: 0.75rem;
        white-space: nowrap;
        flex-shrink: 0;
    }
    
    .status-item i {
        font-size: 0.8rem;
    }
    
    /* 缩放控件 */
    .zoom-controls {
        position: absolute !important;
        bottom: 10px;
        right: 10px;
        padding: 4px 6px;
    }
    
    .zoom-btn {
        width: 32px;
        height: 32px;
    }
    
    /* 搜索框 */
    #component-search {
        padding: 10px 12px 10px 36px;
        font-size: 0.9rem;
    }
    
    /* 分页控制 */
    .pagination-controls {
        padding: 6px 10px;
        margin-bottom: 12px;
    }
    
    .pagination-btn {
        width: 28px;
        height: 28px;
    }
    
    /* 模态框适配 */
    .modal-content {
        width: 95%;
        max-width: 95%;
        padding: 20px;
    }
    
    .modal-header h2 {
        font-size: 1.3rem;
    }
    
    .modal-btn {
        padding: 10px 16px;
        font-size: 0.95rem;
        min-width: 100px;
    }
}

@media (max-width: 600px) {
    .header {
        padding: 12px 15px;
    }
   
    .logo h1 {
        font-size: 1.4rem;
    }
   
    .controls {
        gap: 8px;
        flex-wrap: wrap;
        justify-content: flex-end;
    }
   
    .btn {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
   
    .btn span {
        display: none;
    }
   
    .btn i {
        font-size: 1.1rem;
        width: auto;
    }
   
    #theme-toggle span {
        display: none;
    }
   
    .main-container {
        padding: 0;
        gap: 0;
    }
   
    /* 组件网格更密集 */
    .components-grid {
        grid-template-columns: repeat(7, 1fr);
        gap: 6px;
    }
    
    .component {
        width: 38px;
        height: 38px;
    }
    
    .component img {
        width: 30px;
        height: 30px;
    }
    
    /* 状态栏更紧凑 */
    .status-bar {
        padding: 6px 8px;
        /* 隐藏滚动条但保持滚动功能 */
        scrollbar-width: none; /* Firefox */
        -ms-overflow-style: none; /* IE/Edge */
    }
    
    .status-bar::-webkit-scrollbar {
        display: none; /* Chrome/Safari/Opera */
    }
    
    .status-item {
        padding: 4px 8px;
        font-size: 0.7rem;
    }
   
    /* 缩放控件保持绝对定位 */
    .zoom-controls {
        position: absolute !important;
        bottom: 8px;
        right: 8px;
        padding: 4px 6px;
    }
   
    .zoom-btn {
        width: 30px;
        height: 30px;
        font-size: 0.75rem;
    }
    
    /* 侧边栏按钮 */
    .sidebar-toggle {
        width: 36px;
        height: 36px;
        left: 8px;
        top: 75px;
    }
    
    .sidebar-toggle i {
        font-size: 16px;
    }
    
    /* 组件面板高度调整 */
    #components-panel {
        max-height: 40vh;
        padding: 12px;
    }
    
    .panel-header {
        margin-bottom: 12px;
        padding-bottom: 10px;
    }
    
    .panel-header h2 {
        font-size: 1rem;
    }
    
    #component-search {
        padding: 8px 10px 8px 32px;
        font-size: 0.85rem;
    }
    
    .search-icon {
        left: 10px;
        font-size: 0.85rem;
    }
}

/* 动画效果 */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.category, .component, .btn, .status-item {
    animation: fadeIn 0.4s ease forwards;
}

.category:nth-child(1) { animation-delay: 0.1s; }
.category:nth-child(2) { animation-delay: 0.2s; }
.category:nth-child(3) { animation-delay: 0.3s; }
.category:nth-child(4) { animation-delay: 0.4s; }

/* 模态框 - 优化版 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(3px);
}

.modal-content {
    background: var(--panel);
    padding: 30px;
    border-radius: 16px;
    width: 500px;
    max-width: 90%;
    box-shadow: var(--shadow);
    position: relative;
    transform: translateY(-20px);
    opacity: 0;
    transition: all 0.3s ease-out;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

.modal.show .modal-content {
    transform: translateY(0);
    opacity: 1;
}

.modal-header {
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 15px;
    border-bottom: 2px solid rgba(231, 76, 60, 0.2);
}

.modal-header h2 {
    color: var(--accent);
    font-size: 1.6rem;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
}

.modal-header h2 i {
    font-size: 1.4rem;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(231, 76, 60, 0.1);
}

.modal-body {
    margin-bottom: 25px;
    padding: 10px 0;
    flex: 1;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* 统一按钮大小 */
.modal-footer .modal-btn {
    flex: 1;
}

.close-modal {
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.close-modal:hover {
    color: var(--accent);
    background: rgba(231, 76, 60, 0.1);
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: 500;
    color: var(--text);
    font-size: 1.05rem;
}

.input-group input {
    width: 100%;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--tile);
    color: var(--text);
    font-size: 1.05rem;
    transition: all 0.3s;
}

.input-group input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.2);
}

.modal-btn {
    padding: 12px 28px;
    border-radius: 10px;
    cursor: pointer;
    border: none;
    font-weight: 500;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.05rem;
    min-width: 120px;
    justify-content: center;
}

.primary-btn {
    background: var(--accent);
    color: white;
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}

.secondary-btn {
    background: var(--button-bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.modal-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15);
}

.primary-btn:hover {
    background: #c0392b;
}

.secondary-btn:hover {
    background: var(--button-hover);
}

/* 资源缺失提示 */
.resource-error {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg);
    z-index: 2000;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 20px;
}

.resource-error h2 {
    color: var(--accent);
    margin-bottom: 20px;
}

.resource-error p {
    color: var(--text);
    margin-bottom: 15px;
    max-width: 600px;
    line-height: 1.6;
}

/* 帮助内容样式 */
.help-content {
    padding: 15px;
    background: var(--tile);
    border-radius: 10px;
    max-height: 400px;
    overflow-y: auto;
    line-height: 1.6;
}

.help-content h3 {
    color: var(--accent);
    margin: 20px 0 8px;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.help-content h3 i {
    font-size: 1.1rem;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(231, 76, 60, 0.1);
    border-radius: 50%;
}

.help-content ul {
    padding-left: 20px;
    margin-bottom: 20px;
}

.help-content li {
    margin-bottom: 8px;
    padding-left: 8px;
}

.help-content .highlight {
    background: rgba(231, 76, 60, 0.1);
    padding: 4px 8px;
    border-radius: 6px;
    color: var(--accent);
    font-weight: 500;
    display: inline-block;
    margin: 0 4px;
}

/* 确认信息样式 */
.confirmation-message {
    text-align: center;
    padding: 20px 0;
    font-size: 1.15rem;
    line-height: 1.7;
}

.confirmation-message i {
    font-size: 3.5rem;
    color: var(--accent);
    margin-bottom: 20px;
    display: block;
    opacity: 0.8;
}

.confirmation-message p {
    margin-bottom: 15px;
}

/* 文件上传样式 */
.file-upload {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.file-drop-area {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    transition: all 0.3s;
    background: var(--tile);
    cursor: pointer;
}

.file-drop-area:hover, .file-drop-area.drag-over {
    border-color: var(--accent);
    background: rgba(231, 76, 60, 0.05);
}

.file-drop-area i {
    font-size: 2.5rem;
    color: var(--accent);
    margin-bottom: 15px;
    display: block;
}

.file-drop-text {
    font-size: 1.1rem;
    margin-bottom: 10px;
}

.file-drop-hint {
    color: #888;
    font-size: 0.95rem;
}

/* 状态信息 */
.load-status {
    padding: 15px;
    border-radius: 8px;
    background: var(--tile);
    text-align: center;
    font-size: 1.05rem;
    margin-top: 15px;
}

/* 警告文本样式 */
.warning-text {
    color: var(--accent);
    font-weight: bold;
}

/* 搜索结果提示 */
.search-results {
    margin-top: 10px;
    font-size: 0.9rem;
    color: var(--text);
    padding: 8px;
    border-radius: 6px;
    background: var(--tile);
    display: none;
}
