/* =========================================================
   文字图片生成器 (Text Image Generator)
   专为桌面与移动多端优化的现代视觉样式表
   ========================================================= */

/* 内置特色艺术字体：可口可乐在乎体 */
@font-face {
    font-family: '可口可乐在乎体';
    src: url('../fonts/可口可乐在乎体.ttf') format('truetype'),
        url('/assets/fonts/可口可乐在乎体.ttf') format('truetype');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Coca-Cola Care';
    src: url('../fonts/可口可乐在乎体.ttf') format('truetype'),
        url('/assets/fonts/可口可乐在乎体.ttf') format('truetype');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg-color: #f4f6f9;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-card-solid: #ffffff;
    --border-color: rgba(226, 232, 240, 0.8);
    --border-hover: rgba(255, 82, 119, 0.4);
    --primary: #ff5277;
    --primary-hover: #ff3360;
    --primary-glow: rgba(255, 82, 119, 0.25);
    --secondary: #2d3446;
    --secondary-hover: #1e2433;
    --accent: #6366f1;
    --accent-glow: rgba(99, 102, 241, 0.25);
    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --font-inter: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
    --font-tech: 'Orbitron', 'Fira Code', monospace, sans-serif;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-full: 9999px;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.12);
    --shadow-glow: 0 8px 25px var(--primary-glow);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-inter);
    font-size: 15px;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* 顶部导航统一样式 */
header.navbar {
    position: sticky;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 100;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
}

header.navbar .nav-wrapper {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 64px;
}

header.navbar .logo-group {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

header.navbar .logo {
    font-family: var(--font-tech);
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 1.5px;
    color: var(--secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

header.navbar .logo::before {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    background: var(--primary);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--primary);
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.3);
        opacity: 0.7;
    }
}

.badge-tool {
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    background: rgba(255, 82, 119, 0.08);
    color: var(--primary);
    border: 1px solid rgba(255, 82, 119, 0.25);
    border-radius: var(--radius-full);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-nav-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--secondary);
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    text-decoration: none;
    transition: var(--transition);
}

.btn-nav-back:hover {
    color: var(--primary);
    background: #ffffff;
    border-color: var(--primary);
    transform: translateY(-1px);
}

/* 主工作区布局 (双栏 / 响应式) */
.app-container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 24px 20px 80px;
    width: 100%;
    flex: 1;
    display: grid;
    grid-template-columns: 460px 1fr;
    gap: 28px;
    align-items: start;
}

/* 左侧控制区 */
.control-sidebar {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* 左侧面板头部 */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-title-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--primary);
}

.sidebar-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--secondary);
    margin: 0;
}

.sidebar-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    background: rgba(255, 82, 119, 0.08);
    color: var(--primary);
    border: 1px solid rgba(255, 82, 119, 0.2);
    border-radius: var(--radius-full);
}

/* 左侧面板内容区域 */
.sidebar-content {
    padding: 18px 20px 22px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* =========================================================
   细分单功能操作区 (Single Features Pills & Grid)
   ========================================================= */
.single-features-section {
    margin-bottom: 6px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 16px;
}

.features-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--secondary);
}

.features-section-title i {
    color: var(--primary);
    margin-right: 4px;
}

.features-section-tip {
    font-size: 11.5px;
    font-weight: 400;
    color: var(--text-light);
}

/* 细分功能按钮网格 (精简胶囊按钮，三列自适应) */
.features-pill-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.feature-pill-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 4px;
    padding: 8px 10px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: left;
    position: relative;
    overflow: hidden;
    user-select: none;
}

.feature-pill-btn:hover {
    border-color: var(--primary);
    background: #fffafa;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 82, 119, 0.14);
}

.feature-pill-btn:active {
    transform: translateY(0);
}

.feature-pill-btn i {
    font-size: 13px;
    color: var(--primary);
    margin-bottom: 2px;
}

.feature-pill-btn .pill-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--secondary);
    line-height: 1.2;
}

.feature-pill-btn .pill-badge {
    font-size: 10.5px;
    font-weight: 600;
    color: var(--text-muted);
    background: #f1f5f9;
    padding: 1px 6px;
    border-radius: 4px;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    line-height: 16px;
}

.feature-pill-btn:hover .pill-badge {
    background: #ffe4e6;
    color: var(--primary);
}

.feature-pill-btn .pill-color-indicator {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid #ffffff;
    box-shadow: 0 0 0 1px var(--border-color);
    display: inline-block;
}

/* 模板按钮强调效果 */
.feature-pill-btn.feature-pill-highlight {
    background: linear-gradient(135deg, #fff5f7 0%, #fff 100%);
    border-color: #fecdd3;
}

.feature-pill-btn.feature-pill-highlight:hover {
    border-color: var(--primary);
    background: linear-gradient(135deg, #ffe4e6 0%, #fff 100%);
}

.feature-pill-btn.feature-pill-highlight .pill-badge {
    background: #f43f5e;
    color: #ffffff;
}

/* =========================================================
   单功能独立弹出浮层 (无遮罩高通透 Popover · 实时预览零遮挡)
   ========================================================= */
.feature-popover-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    pointer-events: none; /* 穿透点击，绝不拦截背景及右侧画布交互 */
    display: flex;
    align-items: center;
    justify-content: flex-start; /* 靠左对齐，完全避开右侧画布预览区 */
    padding: 24px;
    padding-left: max(24px, calc((100vw - 1440px) / 2 + 25px));
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.18s ease, visibility 0.18s ease;
}

.feature-popover-backdrop.open {
    opacity: 1;
    visibility: visible;
}

.feature-popover-card {
    pointer-events: auto; /* 浮层本身保持正常点击和交互 */
    background: #ffffff;
    width: 445px;
    max-width: 95vw;
    max-height: 86vh;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(203, 213, 225, 0.95);
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.22), 0 4px 14px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.95) translateY(10px);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.feature-popover-backdrop.open .feature-popover-card {
    transform: scale(1) translateY(0);
}

/* 浮层头部 */
.feature-popover-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
}

.popover-title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.popover-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: rgba(255, 82, 119, 0.1);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.popover-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--secondary);
    line-height: 1.2;
    margin: 0;
}

.popover-subtitle {
    font-size: 11px;
    color: var(--text-light);
    margin: 2px 0 0;
}

.popover-close-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-color);
    background: #ffffff;
    border-radius: var(--radius-full);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: var(--transition);
    flex-shrink: 0;
}

.popover-close-btn:hover {
    color: #ef4444;
    border-color: #ef4444;
    background: #fef2f2;
    transform: rotate(90deg);
}

/* 浮层内容主体 */
.feature-popover-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 22px;
    max-height: calc(88vh - 120px);
}

.single-pane {
    display: none;
    flex-direction: column;
    gap: 16px;
}

.single-pane.active {
    display: flex;
    animation: paneFadeIn 0.2s ease forwards;
}

@keyframes paneFadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 快捷预设按钮组与小输入框 */
.input-field-sm {
    width: 68px;
    padding: 4px 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--secondary);
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    text-align: center;
    outline: none;
    transition: var(--transition);
}

.input-field-sm:focus {
    border-color: var(--primary);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(255, 82, 119, 0.12);
}

.preset-chips-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
}

.preset-chips-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-light);
}

/* 浮层底部操作栏 */
.feature-popover-footer {
    padding: 12px 18px;
    background: #f8fafc;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.popover-live-tip {
    font-size: 12px;
    color: #10b981;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
}

.btn-popover-confirm {
    padding: 7px 18px;
    font-size: 13px;
    font-weight: 600;
    color: #ffffff;
    background: var(--secondary);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-popover-confirm:hover {
    background: var(--primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow);
}

/* 表单组合块 */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.form-label .label-tip {
    font-size: 12px;
    font-weight: 400;
    color: var(--text-muted);
}

/* 快捷标签插入工具栏 */
.tag-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 2px;
}

.tag-toolbar-label {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-tag-insert {
    padding: 3px 9px;
    font-size: 11.5px;
    font-weight: 600;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    color: var(--secondary);
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-tag-insert.btn-icon-only {
    width: 30px;
    height: 28px;
    padding: 0;
    justify-content: center;
    font-size: 13px;
}

.tag-toolbar-divider {
    width: 1px;
    height: 18px;
    background: var(--border-color);
    margin: 0 4px;
}

.btn-tag-insert:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.btn-tag-insert.tag-hl1 {
    color: #b45309;
    background: #fef3c7;
    border-color: #fde68a;
}

.btn-tag-insert.tag-hl1:hover {
    background: #fde68a;
    border-color: #f59e0b;
}

.btn-tag-insert.tag-hl2 {
    color: #be123c;
    background: #ffe4e6;
    border-color: #fecdd3;
}

.btn-tag-insert.tag-hl2:hover {
    background: #fecdd3;
    border-color: #fb7185;
}

/* 输入框通用 */
textarea.input-field,
input[type="text"].input-field {
    width: 100%;
    padding: 12px 14px;
    font-family: inherit;
    font-size: 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: #ffffff;
    color: var(--text-main);
    outline: none;
    transition: var(--transition);
    resize: vertical;
}

textarea.input-field:focus,
input[type="text"].input-field:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

/* 快捷名句按钮 */
.quote-suggest-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.btn-chip {
    padding: 4px 10px;
    font-size: 11px;
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.btn-chip:hover {
    color: var(--primary);
    background: rgba(255, 82, 119, 0.08);
    border-color: rgba(255, 82, 119, 0.3);
}

/* 比例选择器 (Aspect Ratio Grid) */
.ratio-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.ratio-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 4px;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.ratio-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.ratio-card.active {
    background: rgba(255, 82, 119, 0.08);
    border-color: var(--primary);
    color: var(--primary);
    font-weight: 700;
}

.ratio-box-preview {
    border: 1.5px solid currentColor;
    border-radius: 3px;
    margin-bottom: 6px;
    transition: var(--transition);
}

.ratio-text {
    font-size: 12px;
    font-weight: 600;
}

.ratio-desc {
    font-size: 10px;
    color: var(--text-light);
    margin-top: 2px;
}

/* 下拉选择器与网格按钮 */
select.select-field {
    width: 100%;
    padding: 10px 14px;
    font-family: inherit;
    font-size: 13.5px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: #ffffff;
    color: var(--text-main);
    outline: none;
    cursor: pointer;
    transition: var(--transition);
}

select.select-field:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

/* 字体文件动态上传卡片 */
.font-upload-box {
    border: 1.5px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    text-align: center;
    background: #fbfcfe;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.font-upload-box:hover {
    border-color: var(--primary);
    background: rgba(255, 82, 119, 0.03);
}

.font-upload-box input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.font-upload-tip {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* 滑块控制器 */
.slider-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.range-slider {
    flex: 1;
    -webkit-appearance: none;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    outline: none;
}

.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(255, 82, 119, 0.4);
    transition: var(--transition);
}

.range-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.slider-val-badge {
    min-width: 44px;
    padding: 2px 6px;
    font-size: 12px;
    font-family: var(--font-tech);
    background: #f1f5f9;
    color: var(--secondary);
    border-radius: 4px;
    text-align: center;
}

/* 颜色选择器与调色盘 */
.color-picker-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.native-color-picker {
    width: 42px;
    height: 38px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: transparent;
}

.color-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex: 1;
}

.swatch-btn {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1.5px solid rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.swatch-btn:hover {
    transform: scale(1.18);
}

.swatch-btn.active::after {
    content: '✓';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #ffffff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

/* 对齐与样式切换按钮组 */
.btn-toggle-group {
    display: flex;
    background: #f1f5f9;
    padding: 4px;
    border-radius: var(--radius-md);
    gap: 4px;
}

.toggle-opt-btn {
    flex: 1;
    padding: 7px 10px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.toggle-opt-btn.active {
    background: #ffffff;
    color: var(--primary);
    font-weight: 700;
    box-shadow: var(--shadow-sm);
}

/* 大引号装饰样式与符号组 */
.quote-char-group {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.quote-char-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    gap: 2px;
}

.quote-char-btn:hover {
    border-color: var(--primary);
    background: #fffafa;
    transform: translateY(-2px);
}

.quote-char-btn.active {
    background: rgba(255, 82, 119, 0.08);
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(255, 82, 119, 0.18);
}

.quote-char-preview {
    font-size: 26px;
    line-height: 1;
    font-family: 'Georgia', 'Noto Serif SC', serif;
    font-weight: 700;
}

.quote-char-desc {
    font-size: 10.5px;
    color: var(--text-muted);
}

.quote-char-btn.active .quote-char-desc {
    color: var(--primary);
    font-weight: 600;
}

/* 基于当前背景提取的参考色盘 */
.bg-ref-palette {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
}

.bg-ref-swatch {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px 2px;
    background: #ffffff;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    gap: 4px;
    user-select: none;
}

.bg-ref-swatch:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.bg-ref-swatch.active {
    border-color: var(--primary);
    background: #fff5f7;
    box-shadow: 0 0 0 2px rgba(255, 82, 119, 0.25);
}

.bg-ref-swatch-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.12);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.bg-ref-swatch-label {
    font-size: 9.5px;
    color: var(--text-muted);
    line-height: 1.1;
    text-align: center;
    white-space: nowrap;
}

.bg-ref-swatch.active .bg-ref-swatch-label {
    color: var(--primary);
    font-weight: 600;
}

/* 九宫格定位按钮 */
.grid-align-box {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    max-width: 220px;
}

.grid-align-btn {
    height: 36px;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 13px;
    transition: var(--transition);
}

.grid-align-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.grid-align-btn.active {
    background: rgba(255, 82, 119, 0.1);
    border-color: var(--primary);
    color: var(--primary);
}

/* 背景预设展示网格 */
.bg-preset-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.bg-preset-item {
    aspect-ratio: 1;
    border-radius: var(--radius-md);
    border: 2px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.bg-preset-item:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.bg-preset-item.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow);
}

.bg-preset-item.active::after {
    content: '✓';
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--primary);
    color: #ffffff;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 图片上传拖拽区 */
.image-dropzone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px 16px;
    text-align: center;
    background: #fcfdfe;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.image-dropzone:hover,
.image-dropzone.drag-over {
    border-color: var(--primary);
    background: rgba(255, 82, 119, 0.04);
}

.image-dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.dropzone-icon {
    font-size: 28px;
    color: var(--primary);
    margin-bottom: 8px;
}

.dropzone-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--secondary);
}

.dropzone-desc {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 4px;
}

/* 灵感模板卡片网格 */
.templates-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.template-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    background: #ffffff;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.template-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.template-thumb {
    height: 80px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    padding: 8px;
    text-align: center;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    background-size: cover;
    background-position: center;
}

.template-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--secondary);
}

.template-tags {
    font-size: 11px;
    color: var(--text-light);
}

/* =========================================================
   右侧实时画布预览区
   ========================================================= */
.preview-section {
    position: sticky;
    top: 84px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
    min-height: 580px;
}

.preview-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 8px;
}

.preview-status {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.preview-status .dot {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
}

.badge-ratio-indicator {
    font-size: 11.5px;
    font-family: var(--font-tech);
    padding: 2px 8px;
    background: rgba(255, 82, 119, 0.08);
    color: var(--primary);
    border: 1px solid rgba(255, 82, 119, 0.25);
    border-radius: var(--radius-full);
    margin-left: 4px;
    font-weight: 600;
}

.preview-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-toggle-drag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 13px;
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
    background: #ffffff;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.btn-toggle-drag:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(255, 82, 119, 0.05);
}

.btn-toggle-drag.active {
    background: rgba(255, 82, 119, 0.12);
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(255, 82, 119, 0.2);
}

.btn-toggle-drag.locked {
    background: #f8fafc;
    color: var(--text-muted);
    border-color: var(--border-color);
}

.canvas-viewport-wrapper {
    width: 100%;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 520px;
    min-height: 400px;
    max-height: 560px;
    padding: 24px;
    box-sizing: border-box;
    background-color: #111722;
    /* 斜向对比斑纹背景 (Zebra Stripes)，确保任何同色或暗色图片均能清晰辨识边缘与比例 */
    background-image: repeating-linear-gradient(-45deg,
            #0e141f,
            #0e141f 14px,
            #1c2538 14px,
            #1c2538 28px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.45);
}

/* 核心绘制 Canvas - 采用自适应 contain 规则，严禁发生画面溢出和底部截断 */
#render-canvas {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 6px;
    outline: 1.5px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 16px 45px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(0, 0, 0, 0.4);
    cursor: default;
    user-select: none;
    -webkit-user-drag: none;
    transition: transform 0.1s ease, box-shadow 0.2s ease;
    touch-action: auto;
    display: block;
}

#render-canvas.draggable-active {
    cursor: grab;
    touch-action: none;
}

#render-canvas.draggable-active:active {
    cursor: grabbing;
}

.canvas-drag-hint {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.78);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: rgba(255, 255, 255, 0.85);
    font-size: 11.5px;
    padding: 5px 14px;
    border-radius: var(--radius-full);
    pointer-events: auto;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    transition: all 0.2s ease;
    user-select: none;
    white-space: nowrap;
    z-index: 10;
}

.canvas-drag-hint:hover {
    background: rgba(15, 23, 42, 0.95);
    border-color: rgba(255, 82, 119, 0.4);
    color: #ffffff;
}

.canvas-drag-hint.active {
    background: rgba(255, 82, 119, 0.88);
    border-color: rgba(255, 82, 119, 1);
    color: #ffffff;
    box-shadow: 0 2px 12px rgba(255, 82, 119, 0.4);
}

/* 操作动作条 */
.action-toolbar {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    padding-top: 6px;
}

.action-btn-group {
    display: flex;
    gap: 10px;
    flex: 1;
}

.action-icon-group {
    display: flex;
    gap: 8px;
}

.btn-action-primary {
    flex: 2;
    padding: 12px 20px;
    background: linear-gradient(135deg, var(--primary), #ff3360);
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: var(--shadow-glow);
    transition: var(--transition);
}

.btn-action-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(255, 82, 119, 0.4);
}

.btn-action-primary:active {
    transform: translateY(0);
}

.btn-action-secondary {
    flex: 1;
    padding: 12px 16px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--secondary);
    font-size: 13.5px;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: var(--transition);
}

.btn-action-secondary:hover {
    border-color: var(--secondary);
    background: #f8fafc;
    transform: translateY(-1px);
}

.btn-action-icon {
    padding: 12px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-action-icon:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: rgba(255, 82, 119, 0.05);
}

/* 消息提示框 (Toast) */
.toast-msg {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(12px);
    color: #ffffff;
    padding: 10px 22px;
    border-radius: var(--radius-full);
    font-size: 13.5px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
}

.toast-msg.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* 页脚 */
footer.app-footer {
    border-top: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.6);
    padding: 24px 20px;
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
    margin-top: auto;
}

/* =========================================================
   移动端与多端响应式适配 (Responsive Styles)
   ========================================================= */
@media (max-width: 1024px) {
    .app-container {
        grid-template-columns: 1fr;
        gap: 20px;
        padding-bottom: 90px;
    }

    .preview-section {
        position: relative;
        top: 0;
        min-height: auto;
        order: -1;
        /* 让移动端优先看到画布效果 */
    }

    .canvas-viewport-wrapper {
        flex: none;
        width: 100%;
        height: 420px;
        min-height: 340px;
        max-height: 460px;
        padding: 24px;
        box-sizing: border-box;
    }

    #render-canvas {
        max-width: 100%;
        max-height: 100%;
    }

    .tab-content-panel {
        max-height: none;
    }

    /* 中等屏幕/平板下细分功能按钮紧凑排布 (5列 x 3行，大幅节省垂直空间) */
    .single-features-section {
        margin-bottom: 4px;
        padding-bottom: 12px;
        gap: 8px;
    }

    .features-pill-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 6px;
    }

    .feature-pill-btn {
        display: grid;
        grid-template-columns: 18px minmax(0, 1fr);
        grid-template-rows: auto auto;
        column-gap: 6px;
        row-gap: 2px;
        align-items: center;
        padding: 5px 8px;
        border-radius: 7px;
    }

    .feature-pill-btn i {
        grid-column: 1;
        grid-row: 1 / span 2;
        font-size: 13px;
        margin-bottom: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .feature-pill-btn .pill-title {
        grid-column: 2;
        grid-row: 1;
        font-size: 11px;
        line-height: 1.2;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .feature-pill-btn .pill-badge {
        grid-column: 2;
        grid-row: 2;
        font-size: 9.5px;
        line-height: 14px;
        height: 14px;
        padding: 0 4px;
        border-radius: 3px;
        width: fit-content;
        max-width: 100%;
    }

    .feature-pill-btn .pill-color-indicator {
        grid-column: 2;
        grid-row: 2;
        width: 13px;
        height: 13px;
    }

    .action-toolbar {
        padding-top: 4px;
        gap: 10px;
    }

    .btn-action-primary {
        padding: 9px 16px;
        font-size: 13px;
        height: 38px;
    }

    .btn-action-secondary {
        padding: 9px 14px;
        font-size: 12.5px;
        height: 38px;
    }

    .btn-action-icon {
        width: 38px;
        height: 38px;
        padding: 0;
        font-size: 13px;
    }
}

@media (max-width: 640px) {
    header.navbar .nav-wrapper {
        padding: 0 16px;
        height: 56px;
    }

    header.navbar .logo {
        font-size: 18px;
    }

    .badge-tool {
        display: none;
    }

    .app-container {
        padding: 12px 12px 100px;
    }

    .preview-section {
        padding: 14px 12px;
        gap: 12px;
    }

    .preview-header {
        padding-bottom: 10px;
    }

    .btn-toggle-drag {
        padding: 4px 10px;
        font-size: 11.5px;
    }

    .canvas-viewport-wrapper {
        flex: none;
        /* 禁用 flex: 1 避免 height 塌陷 */
        width: 100%;
        height: 370px;
        /* 充足视口高度，容纳各种长宽比及四周完整内边距 */
        min-height: 320px;
        max-height: 420px;
        padding: 24px 20px;
        /* 移动端完全显示清晰的四周内边距，确保上下左右绝不贴边截断 */
        box-sizing: border-box;
    }

    #render-canvas {
        max-width: 100%;
        max-height: 100%;
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(0, 0, 0, 0.35);
    }

    .canvas-drag-hint {
        bottom: 0;
        font-size: 10.5px;
        padding: 3px 10px;
    }

    .tab-content-panel {
        padding: 16px 12px;
    }

    .ratio-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .bg-preset-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .templates-list {
        grid-template-columns: 1fr;
    }

    .action-toolbar {
        width: 100%;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        border-top: 1px solid var(--border-color);
        padding: 7px 10px calc(7px + env(safe-area-inset-bottom, 0px));
        gap: 8px;
        z-index: 90;
        box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06);
    }

    .action-btn-group {
        gap: 6px;
        min-width: 0;
    }

    .action-icon-group {
        gap: 6px;
        flex-shrink: 0;
    }

    .btn-action-primary {
        flex: 1.3;
        padding: 6px 10px;
        font-size: 12px;
        font-weight: 700;
        height: 34px;
        border-radius: 8px;
        gap: 5px;
        white-space: nowrap;
        box-shadow: 0 4px 12px rgba(255, 82, 119, 0.3);
    }

    .btn-action-primary i {
        font-size: 11.5px;
    }

    .btn-action-secondary {
        flex: 1;
        padding: 6px 8px;
        font-size: 11.5px;
        height: 34px;
        border-radius: 8px;
        gap: 4px;
        white-space: nowrap;
    }

    .btn-action-secondary i {
        font-size: 11.5px;
    }

    .btn-action-icon {
        width: 34px;
        height: 34px;
        padding: 0;
        font-size: 12.5px;
        border-radius: 8px;
        flex-shrink: 0;
    }

    /* 移动端/小屏操作区头部与内容区轻量化内边距 */
    .sidebar-header {
        padding: 10px 14px;
    }

    .sidebar-title {
        font-size: 14px;
    }

    .sidebar-content {
        padding: 12px 14px 16px;
        gap: 12px;
    }

    .single-features-section {
        margin-bottom: 2px;
        padding-bottom: 10px;
        gap: 6px;
    }

    .features-section-title {
        font-size: 11.5px;
    }

    .features-section-tip {
        font-size: 10px;
    }

    /* 移动端细分功能按钮极致紧凑排布 (3列 x 5行，左右图文结构，高度大幅压缩节省空间) */
    .features-pill-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 5px;
    }

    .feature-pill-btn {
        display: grid;
        grid-template-columns: 16px minmax(0, 1fr);
        grid-template-rows: auto auto;
        column-gap: 5px;
        row-gap: 1px;
        align-items: center;
        padding: 4px 6px;
        border-radius: 6px;
        min-height: 34px;
    }

    .feature-pill-btn i {
        grid-column: 1;
        grid-row: 1 / span 2;
        font-size: 11.5px;
        margin-bottom: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .feature-pill-btn .pill-title {
        grid-column: 2;
        grid-row: 1;
        font-size: 10.5px;
        line-height: 1.15;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .feature-pill-btn .pill-badge {
        grid-column: 2;
        grid-row: 2;
        font-size: 9px;
        line-height: 13px;
        height: 13px;
        padding: 0 3px;
        border-radius: 3px;
        width: fit-content;
        max-width: 100%;
    }

    .feature-pill-btn .pill-color-indicator {
        grid-column: 2;
        grid-row: 2;
        width: 12px;
        height: 12px;
    }

    /* 格式标签工具栏按钮在小屏状态下更加小巧紧凑 */
    .tag-toolbar {
        padding: 4px 6px;
        gap: 4px;
    }

    .tag-toolbar-label {
        font-size: 11px;
    }

    .btn-tag-insert {
        padding: 2px 6px;
        font-size: 11px;
        border-radius: 4px;
        gap: 3px;
    }

    .btn-tag-insert.btn-icon-only {
        width: 26px;
        height: 24px;
        font-size: 11px;
    }

    .tag-toolbar-divider {
        height: 14px;
        margin: 0 2px;
    }

    /* 快捷示例灵感按钮紧凑化 */
    .quote-suggest-wrap {
        gap: 4px;
        margin-top: 3px;
    }

    .btn-chip {
        padding: 2px 7px;
        font-size: 10.5px;
    }

    textarea.input-field {
        padding: 8px 10px;
        font-size: 13px;
    }

    input[type="text"].input-field {
        padding: 8px 10px;
        font-size: 13px;
    }

    .feature-popover-backdrop {
        padding: 0;
        align-items: flex-end;
    }

    .feature-popover-card {
        width: 100%;
        max-width: 100%;
        max-height: 85vh;
        border-radius: 20px 20px 0 0;
        transform: translateY(100%);
    }

    .feature-popover-backdrop.open .feature-popover-card {
        transform: translateY(0);
    }

    .feature-popover-header {
        padding: 12px 16px;
    }

    .feature-popover-body {
        padding: 16px;
        max-height: calc(85vh - 120px);
    }
}

@media (max-width: 380px) {
    .sidebar-content {
        padding: 10px 10px 14px;
    }

    .features-pill-grid {
        gap: 4px;
    }

    .feature-pill-btn {
        padding: 3px 4px;
        column-gap: 3px;
        min-height: 32px;
    }

    .feature-pill-btn i {
        font-size: 10px;
    }

    .feature-pill-btn .pill-title {
        font-size: 10px;
    }

    .feature-pill-btn .pill-badge {
        font-size: 8.5px;
        padding: 0 2px;
        line-height: 12px;
        height: 12px;
    }

    .feature-pill-btn .pill-color-indicator {
        width: 10px;
        height: 10px;
    }

    .tag-toolbar {
        padding: 3px 4px;
        gap: 3px;
    }

    .btn-tag-insert.btn-icon-only {
        width: 23px;
        height: 22px;
    }

    .btn-chip {
        padding: 1px 6px;
        font-size: 10px;
    }

    .action-toolbar {
        padding: 5px 6px calc(5px + env(safe-area-inset-bottom, 0px));
        gap: 5px;
    }

    .action-btn-group {
        gap: 4px;
    }

    .action-icon-group {
        gap: 4px;
    }

    .btn-action-primary {
        padding: 4px 6px;
        font-size: 10.5px;
        height: 30px;
        border-radius: 6px;
        gap: 3px;
    }

    .btn-action-primary i {
        font-size: 10px;
    }

    .btn-action-secondary {
        padding: 4px 5px;
        font-size: 10.5px;
        height: 30px;
        border-radius: 6px;
        gap: 3px;
    }

    .btn-action-secondary i {
        font-size: 10px;
    }

    .btn-action-icon {
        width: 30px;
        height: 30px;
        font-size: 11px;
        border-radius: 6px;
    }
}