.igs-tool-wrapper { --p-bg: #ffffff; --p-border: #e2e8f0; --p-primary: #E1306C; --p-text: #0f172a; width: 100%; max-width: 1300px; margin: 0 auto; background: var(--p-bg); border-radius: 20px; padding: 24px; border: 1px solid var(--p-border); box-shadow: 0 10px 25px -5px rgba(0,0,0,0.05); box-sizing: border-box; }
.igs-header-main { font-size: 1.6rem; font-weight: 800; color: var(--p-text); margin-bottom: 8px; text-align: center; }
.igs-subtitle { color: #64748b; font-size: 0.95rem; padding-bottom: 20px; border-bottom: 1px solid var(--p-border); margin-bottom: 24px; text-align: center; max-width: 800px; margin-left: auto; margin-right: auto; line-height: 1.6; }

/* 上下结构单栏布局 */
.igs-layout { display: flex; flex-direction: column; gap: 24px; }

/* 面板样式 */
.igs-panel { display: flex; flex-direction: column; background: #f8fafc; border: 1px solid var(--p-border); border-radius: 16px; overflow: hidden; padding: 0; box-sizing: border-box; }
.igs-preview-panel { background: #111827; padding: 24px; display: flex; align-items: center; justify-content: flex-start; flex-direction: column; box-sizing: border-box; }
.igs-panel-title { font-size: 1.05rem; font-weight: 700; color: #334155; padding: 20px; border-bottom: 1px solid var(--p-border); background: #ffffff; margin: 0; }
.igs-preview-panel .igs-panel-title { background: #1f2937; color: #f3f4f6; border-bottom: none; }

/* 配置区的多列网格布局 */
.igs-config-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(350px, 1fr)); gap: 24px; padding: 24px; box-sizing: border-box; }
.igs-config-section { display: flex; flex-direction: column; }
.igs-section-title { font-size: 0.95rem; font-weight: 700; color: #475569; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; border-bottom: 1px dashed #cbd5e1; padding-bottom: 10px; }

.igs-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.igs-form-group { display: flex; flex-direction: column; margin-bottom: 12px; }
.igs-label { font-size: 0.85rem; font-weight: 600; color: #64748b; margin-bottom: 6px; }

.igs-input, .igs-select, .igs-textarea { width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid #cbd5e1; background: #ffffff; color: var(--p-text); font-size: 0.95rem; outline: none; transition: 0.2s; box-sizing: border-box; }
.igs-textarea { resize: vertical; min-height: 100px; font-family: inherit; }
.igs-input:focus, .igs-select:focus, .igs-textarea:focus { border-color: var(--p-primary); box-shadow: 0 0 0 3px rgba(225, 48, 108, 0.15); }

/* 文件上传 */
.igs-file-upload { display: block; width: 100%; border: 1px dashed #94a3b8; background: #ffffff; border-radius: 8px; padding: 10px; text-align: center; cursor: pointer; transition: 0.2s; box-sizing: border-box; }
.igs-file-upload:hover { border-color: var(--p-primary); background: #fdf2f8; color: var(--p-primary); }
.igs-file-upload input[type="file"] { display: none; }
.igs-file-upload span { font-size: 0.85rem; font-weight: 600; color: #475569; }

/* 悬浮式主题配置栏 (已修复溢出问题) */
.igs-theme-picker-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 16px; margin-top: 24px; padding: 12px 24px; background: #1f2937; border-radius: 12px; box-shadow: 0 4px 15px rgba(0,0,0,0.3); box-sizing: border-box; width: 100%; max-width: 600px; }
.igs-theme-label { font-weight: 700; color: #d1d5db; font-size: 0.95rem; white-space: nowrap; }
.igs-theme-picker { display: flex; flex-wrap: wrap; gap: 12px; flex: 1; min-width: 250px; }
.igs-select-sm { flex: 1; min-width: 150px; padding: 8px; border-radius: 6px; border: 1px solid #4b5563; background: #374151; color: #f3f4f6; font-size: 0.85rem; outline: none; }
.igs-select-sm:focus { border-color: var(--p-primary); }

/* 按钮 */
.igs-btn-primary { background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%); color: white; border: none; padding: 10px 20px; border-radius: 20px; font-weight: 700; font-size: 0.95rem; cursor: pointer; transition: 0.2s; display: flex; align-items: center; gap: 6px; box-shadow: 0 4px 12px rgba(225, 48, 108, 0.3); }
.igs-btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); }

/* ================= 黑夜模式 (工具自身外壳适配) ================= */
[data-theme="dark"] .igs-tool-wrapper { background: #1e293b; border-color: #334155; }
[data-theme="dark"] .igs-header-main { color: #f8fafc; }
[data-theme="dark"] .igs-panel { background: #0f172a; border-color: #475569; }
[data-theme="dark"] .igs-panel-title { background: #1e293b; border-bottom-color: #475569; color: #f8fafc; }
[data-theme="dark"] .igs-preview-panel { background: #020617; }
[data-theme="dark"] .igs-section-title { border-bottom-color: #334155; }
[data-theme="dark"] .igs-label { color: #cbd5e1; }
[data-theme="dark"] .igs-input, [data-theme="dark"] .igs-select, [data-theme="dark"] .igs-textarea { background: #020617; border-color: #475569; color: #f8fafc; }
[data-theme="dark"] .igs-file-upload { background: #1e293b; border-color: #475569; }


/* =======================================================
   独立封装的 Instagram Story 渲染引擎 (9:16 画幅)
   ======================================================= */
.igs-preview-container { width: 100%; display: flex; justify-content: center; margin-top: 20px; overflow: hidden; box-sizing: border-box; }

.igs-mockup-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    width: 100%;
    max-width: 380px; /* 模拟手机宽度 */
    aspect-ratio: 9 / 16; /* 核心：9:16 画幅 */
    background-color: #000000;
    border-radius: 16px; /* 现代手机圆角 */
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* 背景大图层 */
.igs-mockup-bg { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; z-index: 1; }

/* 顶底黑灰色渐变遮罩 (为了让白色UI和文字能看清) */
.igs-mockup-gradient { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; background: linear-gradient(to bottom, rgba(0,0,0,0.5) 0%, transparent 15%, transparent 85%, rgba(0,0,0,0.5) 100%); }

/* 顶层 UI 容器 */
.igs-mockup-ui { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 3; display: flex; flex-direction: column; justify-content: space-between; box-sizing: border-box; }

/* 顶部区域 */
.igs-mockup-top { padding: 12px 16px 0 16px; }
.igs-mockup-progress { width: 100%; height: 2px; background: rgba(255,255,255,0.3); border-radius: 2px; margin-bottom: 12px; overflow: hidden; }
.igs-mockup-progress-bar { width: 45%; height: 100%; background: #ffffff; border-radius: 2px; }

.igs-mockup-header { display: flex; justify-content: space-between; align-items: center; }
.igs-mockup-header-left { display: flex; align-items: center; }
.igs-mockup-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; margin-right: 10px; border: 1px solid rgba(255,255,255,0.2); }
.igs-mockup-username { font-weight: 600; font-size: 13px; color: #ffffff; text-shadow: 0 1px 3px rgba(0,0,0,0.3); margin-right: 6px; }
.igs-mockup-time { font-size: 13px; color: rgba(255,255,255,0.8); text-shadow: 0 1px 3px rgba(0,0,0,0.3); }

.igs-mockup-header-right { display: flex; align-items: center; }
.igs-icon { stroke: #ffffff; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; width: 24px; height: 24px; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3)); }
.igs-mockup-header-right svg circle { fill: #ffffff; stroke: none; }

/* 新增：定位贴纸 */
.igs-mockup-location-wrap { width: 100%; display: flex; justify-content: center; margin-top: 20px; }
.igs-mockup-location { display: inline-flex; align-items: center; gap: 4px; background: rgba(255,255,255,0.95); color: #E1306C; padding: 6px 14px; border-radius: 8px; font-weight: 700; font-size: 14px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.igs-mockup-location svg { width: 16px; height: 16px; fill: currentColor; }

/* 中间文字层 */
.igs-mockup-text-overlay { flex: 1; display: flex; align-items: center; justify-content: center; padding: 20px; text-align: center; font-weight: 700; text-shadow: 0 2px 8px rgba(0,0,0,0.6); }
/* 强制文字换行，不保留HTML源码缩进空格 */
.igs-mockup-text-overlay span { white-space: pre-wrap; word-break: break-word; overflow-wrap: break-word; font-family: inherit; }

/* 底部互动区 */
.igs-mockup-bottom { display: flex; align-items: center; gap: 16px; padding: 0 16px 20px 16px; }
.igs-mockup-reply { flex: 1; height: 44px; border-radius: 22px; border: 1px solid #ffffff; display: flex; align-items: center; padding: 0 16px; background: rgba(0,0,0,0.1); backdrop-filter: blur(2px); }
.igs-reply-text { color: #ffffff; font-size: 14px; font-weight: 500; }
.igs-icon-heart, .igs-icon-share { color: #ffffff; width: 28px; height: 28px; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3)); }

/* ================= 移动端强力自适应适配 ================= */
@media (max-width: 650px) {
    .igs-tool-wrapper { padding: 16px; }
    .igs-preview-panel { padding: 16px 12px; }
    .igs-theme-picker-bar { flex-direction: column; gap: 12px; padding: 16px; border-radius: 8px; }
    .igs-select-sm { width: 100%; }
    
    /* 缩小预览外壳，取消边框以贴合手机原样 */
    .igs-mockup-wrapper { border-radius: 0; max-width: 100%; box-shadow: none; }
    
    .igs-config-grid { grid-template-columns: 1fr; padding: 16px; gap: 16px; }
    .igs-form-row { grid-template-columns: 1fr; gap: 12px; }
}