.lim-mosaic-app {
    --lim-primary: #6366f1;
    --lim-primary-2: #8b5cf6;
    --lim-bg: #f8fafc;
    --lim-card: #ffffff;
    --lim-border: #e2e8f0;
    --lim-text: #1e293b;
    --lim-text-muted: #64748b;
    --lim-shadow: 0 4px 24px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);

    max-width: 1100px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
    color: var(--lim-text);
    line-height: 1.5;
}

.lim-mosaic-app *,
.lim-mosaic-app *::before,
.lim-mosaic-app *::after {
    box-sizing: border-box;
}

/* ---------- 卡片 ---------- */
.lim-mosaic-app .lim-card {
    background: var(--lim-card);
    border-radius: 16px;
    box-shadow: var(--lim-shadow);
    overflow: hidden;
}

/* ---------- 顶栏 ---------- */
.lim-mosaic-app .lim-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    border-bottom: 1px solid var(--lim-border);
    gap: 12px;
}

.lim-mosaic-app .lim-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 16px;
}

.lim-mosaic-app .lim-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--lim-primary), var(--lim-primary-2));
    color: #fff;
    font-size: 15px;
    flex-shrink: 0;
}

.lim-mosaic-app .lim-badge {
    font-size: 12px;
    color: #059669;
    background: #ecfdf5;
    padding: 4px 10px;
    border-radius: 999px;
    font-weight: 500;
    white-space: nowrap;
}

/* ---------- 舞台 / 空状态 ---------- */
.lim-mosaic-app .lim-stage {
    padding: 24px;
    background: var(--lim-bg);
}

.lim-mosaic-app .lim-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 64px 24px;
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    background: #fff;
    transition: border-color 0.2s, background 0.2s;
    text-align: center;
}

.lim-mosaic-app .lim-empty.lim-dragover {
    border-color: var(--lim-primary);
    background: #eef2ff;
}

.lim-mosaic-app .lim-empty-icon {
    color: #94a3b8;
    margin-bottom: 16px;
}

.lim-mosaic-app .lim-empty h3 {
    margin: 0 0 8px;
    font-size: 18px;
    font-weight: 600;
}

.lim-mosaic-app .lim-empty p {
    margin: 0 0 20px;
    color: var(--lim-text-muted);
    font-size: 14px;
}

.lim-mosaic-app .lim-note {
    font-size: 12px !important;
    color: #94a3b8 !important;
    margin: 16px 0 0 !important;
}

/* ---------- 编辑区 ---------- */
.lim-mosaic-app .lim-editor {
    display: flex;
    justify-content: center;
    background: #0f172a;
    border-radius: 12px;
    overflow: hidden;
}

.lim-mosaic-app .lim-canvas-stack {
    position: relative;
    display: inline-block;
    max-width: 100%;
    line-height: 0;
    cursor: none;
}

.lim-mosaic-app .lim-base {
    display: block;
    max-width: 100%;
    max-height: 70vh;
    width: auto;
    height: auto;
    user-select: none;
    -webkit-user-drag: none;
    touch-action: none;
}

.lim-mosaic-app .lim-brush-cursor {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    transform: translate(-50%, -50%);
    border: 2px solid rgba(255, 255, 255, 0.95);
    box-shadow:
        inset 0 0 0 1px rgba(0, 0, 0, 0.45),
        0 0 0 1px rgba(0, 0, 0, 0.45);
    z-index: 5;
}

/* ---------- 工具栏 ---------- */
.lim-mosaic-app .lim-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 20px;
    padding: 20px 24px;
    border-top: 1px solid var(--lim-border);
    background: #fff;
}

.lim-mosaic-app .lim-control {
    flex: 1 1 180px;
    min-width: 160px;
}

.lim-mosaic-app .lim-control-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: var(--lim-text-muted);
    margin-bottom: 10px;
}

.lim-mosaic-app .lim-val {
    font-weight: 600;
    color: var(--lim-primary);
    font-variant-numeric: tabular-nums;
}

/* 滑块 */
.lim-mosaic-app input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    margin: 0;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    background: linear-gradient(90deg, var(--lim-primary), var(--lim-primary-2));
}

.lim-mosaic-app input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: #fff;
    border: 2px solid var(--lim-primary);
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(99, 102, 241, 0.35);
    cursor: pointer;
    transition: transform 0.15s;
}

.lim-mosaic-app input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.lim-mosaic-app input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #fff;
    border: 2px solid var(--lim-primary);
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(99, 102, 241, 0.35);
    cursor: pointer;
}

.lim-mosaic-app input[type="range"]::-moz-range-track {
    background: transparent;
    height: 6px;
}

/* 按钮 */
.lim-mosaic-app .lim-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
    flex-wrap: wrap;
    align-items: center;
}

.lim-mosaic-app .lim-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    font-family: inherit;
    transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
    white-space: nowrap;
}

.lim-mosaic-app .lim-btn-primary {
    background: linear-gradient(135deg, var(--lim-primary), var(--lim-primary-2));
    color: #fff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.lim-mosaic-app .lim-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.42);
}

.lim-mosaic-app .lim-btn-primary:active {
    transform: translateY(0);
}

.lim-mosaic-app .lim-btn-ghost {
    background: #f1f5f9;
    color: var(--lim-text);
}

.lim-mosaic-app .lim-btn-ghost:hover {
    background: #e2e8f0;
}

.lim-mosaic-app .lim-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* 视觉隐藏 file input（不能 display:none，否则 Safari 会拦截 click） */
.lim-mosaic-app .lim-file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
    opacity: 0;
}

.lim-mosaic-app .lim-file-label {
    position: relative;
    overflow: hidden;
}

/* ---------- 提示 ---------- */
.lim-mosaic-app .lim-tips {
    padding: 0 24px 20px;
    font-size: 13px;
    color: var(--lim-text-muted);
    text-align: center;
    background: #fff;
}

.lim-mosaic-app .lim-size {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    background: #f1f5f9;
    border-radius: 999px;
    font-size: 12px;
    color: var(--lim-text-muted);
    font-variant-numeric: tabular-nums;
}

/* 对比原图按下态 */
.lim-mosaic-app .lim-compare:active {
    background: #e2e8f0;
}

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
    .lim-mosaic-app .lim-topbar {
        padding: 12px 16px;
        flex-wrap: wrap;
    }
    .lim-mosaic-app .lim-brand {
        font-size: 14px;
    }
    .lim-mosaic-app .lim-badge {
        display: none;
    }
    .lim-mosaic-app .lim-stage {
        padding: 16px;
    }
    .lim-mosaic-app .lim-empty {
        padding: 48px 16px;
    }
    .lim-mosaic-app .lim-toolbar {
        padding: 16px;
        gap: 16px;
    }
    .lim-mosaic-app .lim-actions {
        margin-left: 0;
        width: 100%;
    }
    .lim-mosaic-app .lim-actions .lim-btn {
        flex: 1 1 auto;
    }
    .lim-mosaic-app .lim-base {
        max-height: 55vh;
    }
}