#app *, #app *::before, #app *::after { box-sizing: border-box; margin: 0; padding: 0; }
#app {
    --bg: #fbfbfd;
    --surface: #ffffff;
    --surface2: #f5f6f8;
    --border: #e5e5e7;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --accent: #7c3aed;
    --text: #1d1d1f;
    --text-dim: #86868b;
    --danger: #ef4444;
    --success: #10b981;
    --radius: 12px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}
#app .container { max-width: 1040px; margin: 0 auto; padding: 40px 24px; }

#app .card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    margin-bottom: 24px;
}
#app .card-title {
    font-size: 1.05rem; font-weight: 600; margin-bottom: 20px;
    display: flex; align-items: center; gap: 10px;
}
#app .card-title .card-ico { color: var(--primary); display: inline-flex; }
#app .card-title .badge {
    margin-left: auto; font-size: 0.75rem; font-weight: 500;
    color: var(--text-dim); background: var(--surface2);
    padding: 3px 10px; border-radius: 20px;
}
#app .card-title svg { vertical-align: middle; }

/* ---------- 上传 ---------- */
#app .dropzone {
    border: 2px dashed #d2d2d7; border-radius: var(--radius);
    padding: 46px 20px; text-align: center; cursor: pointer;
    transition: all .2s; background: var(--surface); position: relative;
}
#app .dropzone:hover, #app .dropzone.over {
    border-color: var(--primary); background: #f0f6ff;
}
#app .dropzone-icon { color: var(--primary); margin-bottom: 14px; }
#app .dropzone-text { color: var(--text-dim); font-size: 0.95rem; }
#app .dropzone-text strong { color: var(--primary); }
#app .dropzone small { color: #a1a1a6; font-size: 0.82rem; }
#app .dropzone input[type="file"] { display: none; }

#app .psd-warn {
    margin-top: 16px; padding: 12px 14px; border-radius: 8px;
    background: #f0f6ff; color: #3b6fd4; font-size: 0.85rem;
    display: flex; align-items: center; gap: 8px;
}
#app .psd-warn svg { flex: none; vertical-align: middle; }

/* ---------- 信息 ---------- */
#app .info-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px;
}
#app .info-item {
    background: var(--surface2); border-radius: 8px; padding: 12px 14px;
    display: flex; flex-direction: column; gap: 3px;
}
#app .info-k { font-size: 0.76rem; color: var(--text-dim); }
#app .info-v { font-size: 0.95rem; font-weight: 600; word-break: break-all; }

/* ---------- 工具栏 ---------- */
#app .toolbar {
    display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
    margin-bottom: 18px; padding-bottom: 18px; border-bottom: 1px solid var(--border);
}
#app .tool-group { display: flex; gap: 6px; align-items: center; }
#app .tool-label { font-size: 0.82rem; color: var(--text-dim); margin-right: 2px; }
#app .tool-btn {
    min-width: 38px; height: 34px; padding: 0 12px;
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    border-radius: 8px; cursor: pointer; font-size: 0.86rem; transition: all .15s;
}
#app .tool-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
#app .tool-btn:disabled { opacity: .45; cursor: not-allowed; }
#app .tool-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
#app .zoom-label {
    font-size: 0.82rem; color: var(--text-dim); min-width: 52px; text-align: center;
    font-variant-numeric: tabular-nums;
}
#app .tool-spacer { flex: 1; }

/* ---------- 画布 ---------- */
#app .canvas-wrap {
    border: 1px solid var(--border); border-radius: 8px; padding: 16px;
    overflow: auto; max-height: 620px; text-align: center;
    background: var(--surface2); transition: background .2s;
}
#app .canvas-wrap.bg-checker {
    background-color: #e9e9ed;
    background-image:
        linear-gradient(45deg, #cfcfd6 25%, transparent 25%, transparent 75%, #cfcfd6 75%),
        linear-gradient(45deg, #cfcfd6 25%, transparent 25%, transparent 75%, #cfcfd6 75%);
    background-size: 16px 16px;
    background-position: 0 0, 8px 8px;
}
#app .canvas-wrap.bg-white { background: #ffffff; }
#app .canvas-wrap.bg-black { background: #1d1d1f; }
#app .canvas-wrap.bg-gray  { background: #9a9a9e; }
#app .canvas-wrap canvas {
    display: inline-block; max-width: none;
    box-shadow: 0 2px 12px rgba(0, 0, 0, .18);
    image-rendering: auto;
}

/* ---------- 图层 ---------- */
#app .layer-toolbar {
    display: flex; gap: 8px; align-items: center; margin-bottom: 14px;
    padding-bottom: 14px; border-bottom: 1px solid var(--border);
}
#app .layer-count { font-size: 0.82rem; color: var(--text-dim); }
#app .layer-list { max-height: 420px; overflow-y: auto; }
#app .layer-row {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: 8px; transition: background .15s;
}
#app .layer-row:hover { background: var(--surface2); }
#app .layer-row.is-group { background: #f7f8fa; font-weight: 600; }
#app .layer-row .layer-name {
    flex: 1; font-size: 0.88rem; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap;
}
#app .layer-row .layer-meta {
    font-size: 0.74rem; color: var(--text-dim); flex: none;
    font-variant-numeric: tabular-nums;
}
#app .eye {
    width: 30px; height: 30px; flex: none; border: none; cursor: pointer;
    background: transparent; border-radius: 6px; position: relative; opacity: .35;
    transition: opacity .15s, background .15s;
}
#app .eye:hover { background: #e8e8ed; }
#app .eye.on { opacity: 1; }
/* 眼睛图标用内联 SVG 做 mask，省一次图标库依赖 */
#app .eye::before {
    content: ''; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
    width: 17px; height: 17px; background: var(--text);
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7Z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E");
    -webkit-mask-repeat: no-repeat; -webkit-mask-position: center; -webkit-mask-size: contain;
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7Z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E");
    mask-repeat: no-repeat; mask-position: center; mask-size: contain;
}
#app .empty-hint { color: var(--text-dim); font-size: 0.88rem; padding: 12px; text-align: center; }

/* ---------- 进度 / 提示 ---------- */
#app .progress-wrap { margin-top: 16px; display: none; }
#app .progress-bar-bg {
    height: 6px; background: var(--surface2); border-radius: 3px; overflow: hidden;
}
#app .progress-bar {
    height: 100%; width: 0; border-radius: 3px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    transition: width .25s;
}
#app .progress-text { font-size: 0.8rem; color: var(--text-dim); margin-top: 6px; }
#app .status-line { font-size: 0.85rem; color: var(--text-dim); margin-top: 10px; min-height: 18px; }

#app .toast {
    position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%) translateY(20px);
    background: #1d1d1f; color: #fff; padding: 12px 24px; border-radius: 8px;
    font-size: 0.9rem; opacity: 0; pointer-events: none; transition: all .3s; z-index: 999;
    max-width: 80vw; text-align: center;
}
#app .toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#app .toast.error { background: var(--danger); }
#app .toast.success { background: var(--success); }

/* ---------- 说明 ---------- */
#app .tip-box {
    background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px;
    padding: 14px 16px; font-size: 0.85rem; color: #92400e; line-height: 1.75;
}
#app .tip-box ul { margin: 6px 0 0 18px; }
#app .tip-box li { margin-bottom: 3px; }

@media (max-width: 640px) {
    #app .container { padding: 24px 14px; }
    #app .card { padding: 20px 16px; }
    #app .info-grid { grid-template-columns: repeat(2, 1fr); }
    #app .layer-row .layer-meta { display: none; }
    #app .toolbar { gap: 8px; }
}
