


.imgobf-app [hidden] { display: none !important; }

/* ---------- 2. 容器与变量 ---------- */
.imgobf-app {
    --c-primary:    #6366f1;
    --c-primary-2:  #8b5cf6;
    --c-primary-dk: #4f46e5;
    --c-primary-dk2:#7c3aed;
    --c-text:       #0f172a;
    --c-text-muted: #64748b;
    --c-border:     #e2e8f0;
    --c-border-str: #cbd5e1;
    --c-bg:         #f8fafc;
    --c-surface:    #ffffff;
    --c-success:    #10b981;
    --c-error:      #ef4444;

    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: 20px;
    padding: 24px;
    margin: 24px 0;
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.04),
        0 12px 40px rgba(15, 23, 42, 0.06);
    max-width: 100%;
    color: var(--c-text);
    line-height: 1.5;
}
.imgobf-app *,
.imgobf-app *::before,
.imgobf-app *::after { box-sizing: border-box; }

/* ---------- 3. 头部 ---------- */
.imgobf-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}
.imgobf-logo {
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--c-primary), var(--c-primary-2));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.35);
}
.imgobf-logo svg { width: 22px; height: 22px; }
.imgobf-heading  { min-width: 0; }
.imgobf-title {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--c-text);
}
.imgobf-subtitle {
    margin: 2px 0 0;
    font-size: 13px;
    color: var(--c-text-muted);
}

/* ---------- 4. 上传区 ---------- */
.imgobf-dropzone {
    border: 2px dashed var(--c-border);
    border-radius: 16px;
    padding: 32px 20px;
    text-align: center;
    cursor: pointer;
    background: var(--c-bg);
    transition: border-color .18s, background .18s, transform .18s;
}
.imgobf-dropzone:hover,
.imgobf-dropzone:focus-visible {
    border-color: var(--c-primary);
    background: #eef2ff;
    outline: none;
}
.imgobf-dropzone[data-state="dragover"] {
    border-color: var(--c-primary);
    background: #e0e7ff;
    transform: scale(1.01);
}
.imgobf-dropzone-inner { pointer-events: none; }
.imgobf-upload-icon {
    width: 44px;
    height: 44px;
    margin: 0 auto 10px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--c-primary), var(--c-primary-2));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.3);
}
.imgobf-upload-icon svg { width: 22px; height: 22px; }
.imgobf-dropzone-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--c-text);
}
.imgobf-dropzone-hint {
    margin: 4px 0 0;
    font-size: 12.5px;
    color: var(--c-text-muted);
}

/* ---------- 5. 画布舞台（含显示尺寸限制） ---------- */
.imgobf-stage {
    position: relative;
    border-radius: 14px;
    overflow: auto;
    max-height: 72vh;
    background-color: #f1f5f9;
    background-image:
        linear-gradient(45deg, #e2e8f0 25%, transparent 25%),
        linear-gradient(-45deg, #e2e8f0 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e2e8f0 75%),
        linear-gradient(-45deg, transparent 75%, #e2e8f0 75%);
    background-size: 18px 18px;
    background-position: 0 0, 0 9px, 9px -9px, -9px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px;
    min-height: 160px;
}

.imgobf-canvas {
    display: block;
    /* 显示尺寸限制：只缩不放 */
    max-width: 100%;
    max-height: calc(72vh - 16px);
    width: auto;
    height: auto;
    object-fit: contain;
    /* 视觉 */
    border-radius: 8px;
    image-rendering: pixelated;
    box-shadow: 0 6px 24px rgba(15, 23, 42, 0.12);
}

/* ---------- 6. 加载遮罩 ---------- */
.imgobf-loading {
    position: absolute;
    inset: 0;
    background: rgba(248, 250, 252, 0.82);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 500;
    color: var(--c-primary);
    z-index: 5;
}
.imgobf-spinner {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 3px solid rgba(99, 102, 241, 0.18);
    border-top-color: var(--c-primary);
    animation: imgobf-spin 0.8s linear infinite;
}
@keyframes imgobf-spin { to { transform: rotate(360deg); } }

/* ---------- 7. 工具栏 ---------- */
.imgobf-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}
.imgobf-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    border-radius: 10px;
    border: 1px solid var(--c-border);
    background: var(--c-surface);
    color: var(--c-text);
    cursor: pointer;
    transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
    user-select: none;
}
.imgobf-btn svg { width: 16px; height: 16px; }
.imgobf-btn:hover:not(:disabled) {
    background: #f1f5f9;
    border-color: var(--c-border-str);
}
.imgobf-btn:active:not(:disabled) { transform: translateY(1px); }
.imgobf-btn:focus-visible {
    outline: 2px solid var(--c-primary);
    outline-offset: 2px;
}
.imgobf-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.imgobf-btn-primary {
    background: linear-gradient(135deg, var(--c-primary), var(--c-primary-2));
    border-color: transparent;
    color: #fff;
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.35);
}
.imgobf-btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--c-primary-dk), var(--c-primary-dk2));
    border-color: transparent;
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.45);
}

.imgobf-btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--c-text-muted);
}
.imgobf-btn-ghost:hover:not(:disabled) {
    background: #f1f5f9;
    border-color: transparent;
    color: var(--c-text);
}

/* 清空按钮：破坏性操作，hover 变红 */
.imgobf-btn-clear { color: var(--c-text-muted); }
.imgobf-btn-clear:hover:not(:disabled) {
    color: var(--c-error);
    background: #fef2f2;
    border-color: transparent;
}

/* 桌面端：清空靠右，与其它操作拉开距离 */
@media (min-width: 481px) {
    .imgobf-toolbar .imgobf-btn-clear { margin-left: auto; }
}

/* ---------- 8. 状态胶囊 ---------- */
.imgobf-status {
    margin-top: 14px;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 500;
    border: 1px solid transparent;
    animation: imgobf-fade .25s ease;
}
.imgobf-status[data-type="info"] {
    background: #eef2ff;
    border-color: #c7d2fe;
    color: #3730a3;
}
.imgobf-status[data-type="success"] {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: #065f46;
}
.imgobf-status[data-type="error"] {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}
@keyframes imgobf-fade {
    from { opacity: 0; transform: translateY(-2px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------- 9. 底部提示 ---------- */
.imgobf-hint {
    margin: 14px 0 0;
    font-size: 12.5px;
    color: var(--c-text-muted);
    line-height: 1.6;
}

/* ---------- 10. 响应式 ---------- */
@media (max-width: 480px) {
    .imgobf-app {
        padding: 18px;
        border-radius: 16px;
    }
    .imgobf-header { gap: 10px; margin-bottom: 16px; }
    .imgobf-title  { font-size: 16px; }
    .imgobf-dropzone { padding: 24px 14px; }

    /* 手机上更保守的高度上限 */
    .imgobf-stage  { max-height: 55vh; }
    .imgobf-canvas { max-height: calc(55vh - 16px); }

    /* 按钮两列栅格，主按钮独占一行 */
    .imgobf-toolbar {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
    .imgobf-btn { justify-content: center; }
    .imgobf-btn-primary { grid-column: 1 / -1; }
}