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

:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #f3f4f6;
    --text-color: #1f2937;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --toolbar-height: 70px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background: #f9fafb;
    color: var(--text-color);
    overflow: hidden;
    height: 100vh;
}

/* 工具栏 */
.toolbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--toolbar-height);
    background: white;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 1000;
}

.toolbar-left,
.toolbar-center,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.toolbar-center {
    flex: 1;
    justify-content: center;
    max-width: 1000px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: 600;
    color: var(--primary-color);
}

.logo-image {
    width: 36px;
    height: 36px;
    animation: logoFloat 3s ease-in-out infinite;
}

@keyframes logoFloat {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-3px);
    }
}

/* 工具按钮 */
.tool-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    color: var(--text-color);
    font-family: inherit;
}

.tool-btn:hover {
    background: var(--secondary-color);
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

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

.tool-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.tool-btn svg {
    stroke-width: 2;
}

.tool-btn.active svg {
    stroke: white;
}

/* 分隔线 */
.divider {
    width: 1px;
    height: 30px;
    background: var(--border-color);
    margin: 0 8px;
}

/* 颜色选择器 */
.color-picker-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.color-preview {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.2s ease;
}

.color-preview:hover {
    border-color: var(--primary-color);
    transform: scale(1.05);
}

.color-preview input[type="color"] {
    position: absolute;
    width: 150%;
    height: 150%;
    top: -25%;
    left: -25%;
    border: none;
    cursor: pointer;
}

.label-text {
    font-size: 12px;
    color: #6b7280;
}

/* 背景颜色选择器 */
.bg-color-picker-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.bg-color-options {
    display: flex;
    gap: 6px;
    padding: 8px;
    background: var(--secondary-color);
    border-radius: 8px;
    flex-wrap: wrap;
    max-width: 200px;
}

.bg-color-btn {
    width: 32px;
    height: 32px;
    padding: 3px;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.bg-color-btn:hover {
    border-color: var(--primary-color);
    transform: scale(1.1);
}

.bg-color-btn.active {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2);
}

.bg-color-preview {
    width: 100%;
    height: 100%;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

/* 笔刷大小控制 */
.size-control {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--secondary-color);
    border-radius: 8px;
}

.size-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.size-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.size-btn:hover svg {
    stroke: white;
}

.size-btn:active {
    transform: scale(0.95);
}

.size-display {
    display: flex;
    align-items: baseline;
    gap: 2px;
    min-width: 50px;
    justify-content: center;
}

#sizeValue {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-color);
}

.size-label {
    font-size: 12px;
    color: #6b7280;
}

/* 画布容器 */
.canvas-container {
    position: fixed;
    top: var(--toolbar-height);
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f9fafb;
    padding: 20px;
}

#whiteboard {
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    cursor: crosshair;
    touch-action: none;
}

.canvas-info {
    position: absolute;
    bottom: 30px;
    left: 30px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border-radius: 6px;
    font-size: 12px;
    font-family: 'Courier New', monospace;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}

.canvas-info.visible {
    opacity: 1;
}

/* 模态框 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal.show {
    display: flex;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow: auto;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-color);
}

.close-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #6b7280;
}

.close-btn:hover {
    background: var(--secondary-color);
    color: var(--text-color);
}

.modal-body {
    padding: 24px;
}

/* 快捷键网格 */
.shortcut-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
}

.shortcut-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--secondary-color);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.shortcut-item:hover {
    background: #e5e7eb;
    transform: translateX(4px);
}

kbd {
    display: inline-block;
    padding: 4px 8px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-color);
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.1);
    min-width: 28px;
    text-align: center;
}

.shortcut-item span {
    font-size: 14px;
    color: #4b5563;
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .toolbar-center {
        gap: 8px;
    }
    
    .tool-btn span {
        display: none;
    }
    
    .tool-btn {
        padding: 10px;
    }
    
    .divider {
        display: none;
    }
    
    .bg-color-options {
        max-width: 160px;
    }
    
    .bg-color-btn {
        width: 28px;
        height: 28px;
    }
}

@media (max-width: 768px) {
    .toolbar {
        padding: 0 10px;
        flex-wrap: wrap;
        height: auto;
        padding-top: 10px;
        padding-bottom: 10px;
    }
    
    .toolbar-left {
        width: 100%;
        justify-content: center;
        margin-bottom: 10px;
    }
    
    .toolbar-center,
    .toolbar-right {
        flex: 1;
    }
    
    .canvas-container {
        top: 100px;
    }
    
    :root {
        --toolbar-height: 100px;
    }
    
    .shortcut-grid {
        grid-template-columns: 1fr;
    }
}

/* 自定义滚动条 */
.modal-content::-webkit-scrollbar {
    width: 8px;
}

.modal-content::-webkit-scrollbar-track {
    background: var(--secondary-color);
    border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb {
    background: #9ca3af;
    border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

/* 画笔预览光标 */
.canvas-container.pen-cursor #whiteboard {
    cursor: crosshair;
}

.canvas-container.eraser-cursor #whiteboard {
    cursor: cell;
}

/* 加载动画 */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.loading {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
