* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    background: #e9ecef; /* 浅灰色背景，与白色画布区分 */
    min-height: 100vh;
    color: #333;
    margin: 0;
    padding: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header h1 {
    color: #667eea;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.login-buttons button {
    margin-left: 10px;
}

.main-content {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.board-list-container h2 {
    margin-bottom: 20px;
    color: #667eea;
}

.board-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.board-item {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid transparent;
}

.board-item:hover {
    border-color: #667eea;
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.board-item h3 {
    margin-bottom: 10px;
    color: #333;
}

.board-item .meta {
    font-size: 12px;
    color: #666;
    margin-bottom: 10px;
}

.board-item .actions {
    display: flex;
    gap: 10px;
}

.btn-primary, .btn-secondary, .btn-tool, button {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-tool {
    background: #f8f9fa;
    color: #333;
    border: 1px solid #dee2e6;
}

.btn-tool:hover {
    background: #e9ecef;
}

.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-box {
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 400px;
}

.auth-box h2 {
    text-align: center;
    margin-bottom: 30px;
    color: #667eea;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: #333;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.auth-link {
    text-align: center;
    margin-top: 20px;
}

.auth-link a {
    color: #667eea;
    text-decoration: none;
}

.auth-link a:hover {
    text-decoration: underline;
}

.board-container {
    background: #e9ecef; /* 浅灰色背景，与白色画布区分 */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    /* 允许页面滚动 */
}

/* 移动端全屏模式（CSS模拟） */
.board-container.mobile-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    background: #e9ecef;
}

.board-container.mobile-fullscreen .board-header {
    display: none;
}

.board-container.mobile-fullscreen .fullscreen-content {
    height: 100vh;
    width: 100vw;
}

.board-header {
    padding: 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.board-title {
    display: flex;
    gap: 10px;
    align-items: center;
}

.board-title input {
    padding: 8px 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
    min-width: 200px;
}

.board-actions {
    display: flex;
    gap: 10px;
}

.fullscreen-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.board-toolbar {
    padding: 15px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
    flex-shrink: 0;
}

.tool-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tool-group label {
    font-weight: 500;
    color: #333;
}

.tool-group input[type="color"] {
    width: 50px;
    height: 35px;
    border: 1px solid #ddd;
    border-radius: 5px;
    cursor: pointer;
}

.tool-group input[type="range"] {
    width: 150px;
}

.canvas-wrapper {
    flex: 1;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start; /* 改为flex-start，允许滚动 */
    background: #e9ecef; /* 与页面背景一致 */
    overflow: auto;
    min-height: 0;
    position: relative;
    width: 100%;
    box-sizing: border-box;
    /* 允许画布超出时滚动 */
}

#drawingCanvas {
    background: white;
    border: 2px solid #dee2e6;
    border-radius: 5px;
    cursor: crosshair;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    /* A4竖版尺寸：210mm × 297mm (96 DPI: 794px × 1123px) */
    /* 实际像素尺寸在JS中设置，这里只设置显示尺寸 */
    display: block;
    /* 显示尺寸由JS根据A4比例计算后设置 */
}

/* 全屏模式下的样式 - 只包含工具栏和画布 */
.fullscreen-content:fullscreen,
.fullscreen-content:-webkit-full-screen,
.fullscreen-content:-moz-full-screen,
.fullscreen-content:-ms-fullscreen {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    background: #e9ecef;
    padding: 0;
}

.fullscreen-content:fullscreen .board-toolbar,
.fullscreen-content:-webkit-full-screen .board-toolbar,
.fullscreen-content:-moz-full-screen .board-toolbar,
.fullscreen-content:-ms-fullscreen .board-toolbar {
    flex-shrink: 0;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.fullscreen-content:fullscreen .canvas-wrapper,
.fullscreen-content:-webkit-full-screen .canvas-wrapper,
.fullscreen-content:-moz-full-screen .canvas-wrapper,
.fullscreen-content:-ms-fullscreen .canvas-wrapper {
    flex: 1;
    overflow: auto;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 0;
}

/* 全屏时画布尺寸由JS根据A4比例计算，这里不设置固定尺寸 */
.fullscreen-content:fullscreen #drawingCanvas,
.fullscreen-content:-webkit-full-screen #drawingCanvas,
.fullscreen-content:-moz-full-screen #drawingCanvas,
.fullscreen-content:-ms-fullscreen #drawingCanvas {
    /* 尺寸由JS的updateCanvasScale函数根据A4比例计算 */
    max-width: none;
    max-height: none;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: white;
    padding: 30px;
    border-radius: 10px;
    max-width: 500px;
    width: 90%;
    position: relative;
}

.close {
    position: absolute;
    right: 15px;
    top: 15px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #aaa;
}

.close:hover {
    color: #000;
}

.modal-content h3 {
    margin-bottom: 20px;
    color: #667eea;
}

.modal-content .form-group {
    margin-bottom: 15px;
}

.modal-content .form-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
}

.modal-content .form-group button {
    margin-left: 10px;
}

.alert {
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 5px;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* 全屏模式样式 */
.canvas-wrapper:-webkit-full-screen {
    background: white;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
}

.canvas-wrapper:-moz-full-screen {
    background: white;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
}

.canvas-wrapper:-ms-fullscreen {
    background: white;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
}

.canvas-wrapper:fullscreen {
    background: white;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
}

#drawingCanvas:-webkit-full-screen {
    width: 794px;
    height: 1123px;
    border: none;
    border-radius: 0;
    max-width: 100vw;
    max-height: 100vh;
    transform: scale(1);
    margin: auto;
}

#drawingCanvas:-moz-full-screen {
    width: 794px;
    height: 1123px;
    border: none;
    border-radius: 0;
    max-width: 100vw;
    max-height: 100vh;
    transform: scale(1);
    margin: auto;
}

#drawingCanvas:-ms-fullscreen {
    width: 794px;
    height: 1123px;
    border: none;
    border-radius: 0;
    max-width: 100vw;
    max-height: 100vh;
    transform: scale(1);
    margin: auto;
}

#drawingCanvas:fullscreen {
    width: 794px;
    height: 1123px;
    border: none;
    border-radius: 0;
    max-width: 100vw;
    max-height: 100vh;
    transform: scale(1);
    margin: auto;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .board-container {
        height: 100vh;
        overflow: hidden;
    }

    .board-header {
        padding: 10px;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .board-title {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
    }

    .board-title input {
        width: 100%;
        min-width: auto;
    }

    .board-actions {
        width: 100%;
        justify-content: space-between;
    }

    .board-toolbar {
        padding: 10px;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .tool-group {
        flex-wrap: wrap;
        justify-content: space-between;
    }

    .tool-group label {
        font-size: 14px;
    }

    .tool-group input[type="range"] {
        width: 120px;
    }

    .canvas-wrapper {
        padding: 5px;
        flex: 1;
        min-height: 0;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    #drawingCanvas {
        width: 794px;
        height: 1123px;
    }

    .btn-tool {
        padding: 8px 12px;
        font-size: 14px;
    }
}

/* 横屏模式适配 */
@media (orientation: landscape) and (max-height: 500px) {
    .board-container {
        height: 100vh;
        display: flex;
        flex-direction: column;
    }

    .canvas-wrapper {
        flex: 1;
        min-height: 0;
    }

    #drawingCanvas {
        width: 794px;
        height: 1123px;
    }
}

/* 手机全屏模式 */
@media screen and (max-width: 768px) and (orientation: portrait) {
    html, body {
        height: 100%;
        overflow: hidden;
        margin: 0;
        padding: 0;
    }

    .board-container {
        height: 100vh;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
        margin: 0;
        padding: 0;
    }

    .board-header {
        padding: 8px;
        flex-wrap: wrap;
    }

    .board-toolbar {
        padding: 8px;
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    .tool-group {
        white-space: nowrap;
        flex-shrink: 0;
    }

    .canvas-wrapper {
        flex: 1;
        min-height: 0;
        padding: 2px;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    #drawingCanvas {
        width: 794px;
        height: 1123px;
        border-radius: 0;
    }
}

/* 横屏模式 - 更宽的屏幕 */
@media screen and (min-width: 769px) and (orientation: landscape) {
    .board-container {
        height: 100vh;
        display: flex;
        flex-direction: column;
    }

    .board-toolbar {
        flex-wrap: wrap;
        overflow-x: auto;
    }

    .canvas-wrapper {
        flex: 1;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    #drawingCanvas {
        width: 794px;
        height: 1123px;
    }
}

