:root {
    --primary-color: #3276fe;
    --bg-color: #f5f5f7;
    --panel-bg: #ffffff;
    --text-color: #333333;
}

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

body {
    font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

header {
    text-align: center;
    margin-bottom: 20px;
}

.header-title-image {
    width: 400px;
    max-width: 100%;
    height: auto;
    display: inline-block;
}

main {
    display: flex;
    gap: 20px;
    flex: 1;
    overflow: hidden;
}

.controls {
    width: 380px;
    background: var(--panel-bg);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-card {
    background: #fafafa;
    border: 1px solid rgba(0,0,0,0.06);
    border-radius: 12px;
    padding: 12px;
}

.input-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.btn-row {
    width: 100%;
}

.btn-row .btn {
    flex: 1 1 0;
}

.btn-row label.btn {
    display: flex;
    justify-content: center;
}

.input-row label {
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.two-col {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px;
    align-items: center;
}

.two-col label {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    min-width: 0;
}

.helper-text {
    font-size: 12px;
    color: #666;
    line-height: 1.4;
}

input[type="text"], input[type="number"] {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    width: 100%;
}

.two-col input[type="number"] {
    width: 100%;
    max-width: 90px;
    min-width: 0;
}

.two-col input[type="color"] {
    width: 44px;
    height: 34px;
    padding: 0;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    text-align: center;
    transition: background 0.2s;
}

.upload-btn {
    background-color: var(--primary-color);
    color: white;
    display: block;
}

.upload-btn:hover {
    background-color: #3276fe;
}

.delete-btn {
    background-color: #e53935;
    color: white;
}

.delete-btn:hover {
    background-color: #d32f2f;
}

.delete-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.download-btn {
    background-color: #27ae60;
    color: white;
}

.download-btn:hover {
    background-color: #219150;
}

.canvas-container {
    flex: 1;
    background: #e0e0e0;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.1);
}

.empty-tip {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 22px;
    font-weight: 700;
    color: rgba(0, 0, 0, 0.55);
    user-select: none;
    pointer-events: none;
}

.mosaic-panel {
    padding: 12px;
}

.mosaic-panel-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
    align-items: center;
}

.mosaic-panel-grid label {
    font-size: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mosaic-panel-grid input[type="number"] {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
}

.mosaic-btn {
    background-color: var(--primary-color);
    color: #fff;
}

.mosaic-btn:hover {
    background-color: #3276fe;
}

.mosaic-cancel-btn {
    background-color: #f0f0f0;
    color: #333;
}

.mosaic-cancel-btn:hover {
    background-color: #e5e5e5;
}

.mosaic-cancel-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.mosaic-selection {
    position: absolute;
    z-index: 9;
    cursor: move;
    touch-action: none;
}

.mosaic-ants {
    width: 100%;
    height: 100%;
    display: block;
}

.ants {
    fill: none;
    stroke-width: 2;
    stroke-dasharray: 7 7;
    animation: ants-move 0.8s linear infinite;
}

.ants-dark {
    stroke: rgba(0,0,0,0.85);
}

.ants-light {
    stroke: rgba(255,255,255,0.95);
    stroke-dashoffset: 7;
}

@keyframes ants-move {
    to {
        stroke-dashoffset: -14;
    }
}

canvas {
    max-width: 100%;
    max-height: 100%;
    box-shadow: 0 0 10px rgba(0,0,0,0.2);
    background: white; /* 透明图片背景 */
}

.tips {
    font-size: 15px;
    color: #666;
    margin-top: auto;
}

.tips ul {
    padding-left: 20px;
    margin-top: 5px;
}

.page-footer {
    font-size: 12px;
    font-weight: 700;
    color: #666;
    text-align: center;
    padding: 10px 0 0;
}

.hidden {
    display: none !important;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.weekend-guard.modal-overlay {
    background: rgba(0, 0, 0, 0.85);
    z-index: 2000;
}

.weekend-guard .modal-content {
    margin-top: 0;
}

.modal-wrapper {
    position: relative;
    width: 90%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.modal-icon {
    position: absolute;
    top: -75px;
    left: 50%;
    width: 250px;
    height: 150px;
    transform: translateX(-50%);
    object-fit: contain;
    pointer-events: none;
    user-select: none;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    margin-top: 75px;
}

.modal-body h3 {
    margin-bottom: 12px;
    font-size: 18px;
    color: #333;
}

.modal-body p {
    margin-bottom: 8px;
    font-size: 14px;
    color: #555;
    line-height: 1.6;
}

.confirm-btn {
    background-color: var(--primary-color);
    color: white;
    width: calc(100% - 120px);
    padding: 12px;
    font-size: 14px;
    margin: 0 auto;
}

.confirm-btn:hover {
    background-color: #3276fe;
}

.page-loader {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(245, 245, 247, 0.995);
    z-index: 3000;
    opacity: 1;
    transition: opacity 220ms ease;
}

.page-loader-icon {
    width: min(420px, calc(100vw - 80px));
    height: auto;
    margin-bottom: 18px;
    object-fit: contain;
}

.page-loader.is-hidden {
    opacity: 0;
    pointer-events: none;
}

.loader {
    position: relative;
    width: 70px;
    height: 70px;
}

.loader-large {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 100%;
    height: 100%;
    background-color: #60a5fa;
    border-radius: 10px;
    animation: loading 2s infinite;
}

.loader-small {
    position: absolute;
    width: 50%;
    height: 50%;
    inset: 0;
    margin: auto;
    background-color: #1d4ed8;
    z-index: 2;
    border-radius: 6px;
    animation: loading 2s infinite reverse;
}

@keyframes loading {
    0% {
        transform: rotate(0deg);
    }

    50% {
        transform: rotateY(180deg);
    }

    100% {
        transform: rotateX(180deg);
    }
}

@media (max-width: 768px) {
    main {
        flex-direction: column;
    }
    .controls {
        width: 100%;
        max-height: none;
        overflow-y: visible;
    }
    .canvas-container {
        min-height: 300px;
    }
}
