/* 基础样式和变量定义 */
:root {
    --primary-color: #4361ee;
    --secondary-color: #3a0ca3;
    --success-color: #4cc9f0;
    --danger-color: #f72585;
    --warning-color: #f8961e;
    --light-color: #f8f9fa;
    --dark-color: #212529;
    --gray-color: #6c757d;
    --light-gray: #e9ecef;
    --border-radius: 12px;
    --box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    --transition: all 0.25s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: #f0f2f5;
    color: var(--dark-color);
    line-height: 1.6;
    padding: 15px;
    min-height: 100vh;
}

@media (min-width: 600px) {
    body { padding: 20px; }
}

.container {
    max-width: 1800px;
    margin: 0 auto;
}

/* 头部样式 */
.header {
    text-align: center;
    padding: 18px 15px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border-radius: var(--border-radius);
    margin-bottom: 16px;
    box-shadow: var(--box-shadow);
}

.header h1 {
    font-size: 1.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.header-sub {
    margin-top: 6px;
    font-size: 0.9rem;
    opacity: 0.9;
    font-weight: 300;
}

/* 工具栏：撤销 / 重做 */
.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    padding: 10px 14px;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    flex-wrap: wrap;
}

.tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 2px solid var(--light-gray);
    border-radius: 8px;
    background: #fff;
    color: var(--dark-color);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}
.tool-btn:hover:not(:disabled) { border-color: var(--primary-color); background: #f0f3ff; color: var(--primary-color); }
.tool-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.toolbar-hint {
    margin-left: auto;
    font-size: 0.8rem;
    color: var(--gray-color);
}

/* 主要内容区域布局 */
.main-content {
    display: grid;
    gap: 25px;
    grid-template-columns: 1fr;
    align-items: stretch; /* 同一行内三栏等高 */
}

@media (min-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr 1.15fr 1.1fr;
    }
}

@media (min-width: 800px) and (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr 1.1fr;
    }
    .right-panel { grid-column: 1 / -1; }
    .header h1 { font-size: 1.7rem; }
}

@media (max-width: 800px) {
    .header h1 { font-size: 1.4rem; flex-direction: column; gap: 8px; }
    .toolbar-hint { margin-left: 0; width: 100%; }
}

/* 通用面板 */
.left-panel, .center-panel, .right-panel {
    background: white;
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--box-shadow);
    display: flex;
    flex-direction: column;
    min-height: 0; /* 允许内部滚动区域正确收缩 */
}

.center-panel, .right-panel { gap: 22px; }

/* ===== 左侧面板 - 图标选择 ===== */
.search-section { margin-bottom: 16px; }

.search-box { position: relative; margin-bottom: 12px; }

.search-box input {
    width: 100%;
    padding: 14px;
    border: 2px solid var(--light-gray);
    border-radius: 8px;
    font-size: 1rem;
    transition: var(--transition);
    background: transparent;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}

.search-clear {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-color);
    cursor: pointer;
    display: none;
    background: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

.search-clear:hover { color: var(--danger-color); background: #f8f9fa; }
.search-clear.visible { display: flex; }

.search-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    color: var(--gray-color);
    flex-wrap: wrap;
    gap: 10px;
}

.category-filter { display: flex; gap: 8px; flex-wrap: wrap; }

#searchCount {
    font-weight: 500;
    font-family: 'Consolas', 'Monaco', monospace;
    background-color: #f0f3ff;
    padding: 4px 10px;
    border-radius: 6px;
    color: var(--primary-color);
    border: 1px solid rgba(67, 97, 238, 0.2);
}

.category-btn {
    padding: 6px 12px;
    background: var(--light-gray);
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
}

.category-btn:hover { background: #d1d5db; }
.category-btn.active { background-color: var(--primary-color); color: white; }

/* 官方主题分类下拉 */
.category-select-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
}
.category-select-row label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--secondary-color);
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.category-select-row select {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid var(--light-gray);
    border-radius: 8px;
    font-size: 0.9rem;
    background: #fff;
    cursor: pointer;
    transition: var(--transition);
}
.category-select-row select:focus { outline: none; border-color: var(--primary-color); }
.category-select-row select:disabled { opacity: 0.6; cursor: not-allowed; }

.left-hint {
    margin-top: 12px;
    font-size: 0.8rem;
    color: var(--gray-color);
    display: flex;
    align-items: center;
    gap: 6px;
}
.left-hint i { color: var(--primary-color); }

/* 图标网格：flex 填充剩余高度并内部滚动（保证三栏等高） */
.icons-grid {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    padding-right: 5px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
    grid-auto-rows: 96px;
    gap: 12px;
    align-content: start;
}

.icons-grid::-webkit-scrollbar { width: 8px; }
.icons-grid::-webkit-scrollbar-track { background: var(--light-gray); border-radius: 4px; }
.icons-grid::-webkit-scrollbar-thumb { background: var(--gray-color); border-radius: 4px; }

.icon-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 14px 8px;
    background: white;
    border: 2px solid var(--light-gray);
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    height: 96px;
    justify-content: center;
}

.icon-item:hover {
    border-color: var(--primary-color);
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.icon-item.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(67, 97, 238, 0.25);
    background: #f5f8ff;
}

.icon-display {
    font-size: 1.7rem;
    margin-bottom: 8px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-item-name {
    font-size: 0.72rem;
    word-break: break-word;
    max-width: 100%;
    line-height: 1.2;
    color: var(--dark-color);
    font-weight: 500;
}

/* 分页控制 */
.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-top: 16px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid var(--light-gray);
    flex-shrink: 0;
}

.page-btn {
    padding: 8px 15px;
    background: white;
    border: 2px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
}

.page-btn:hover:not(.disabled) { border-color: var(--primary-color); background: #f0f3ff; }
.page-btn.disabled { opacity: 0.5; cursor: not-allowed; }
.page-info { font-size: 0.9rem; color: var(--gray-color); font-weight: 500; }

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 50px 20px;
    color: var(--gray-color);
    grid-column: 1 / -1;
}
.empty-state i { font-size: 2.6rem; margin-bottom: 16px; opacity: 0.5; }

/* ===== 中间面板：标题 / 分组通用 ===== */
.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.center-panel h3 {
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.15rem;
}

.editor-layer-name {
    margin-left: auto;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--secondary-color);
    background: #f0f3ff;
    padding: 2px 10px;
    border-radius: 20px;
    border: 1px solid rgba(67,97,238,.15);
}

.btn-add {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: none;
    border-radius: 8px;
    background: var(--primary-color);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}
.btn-add:hover { background: var(--secondary-color); transform: translateY(-1px); }

.layers-hint, .editor-empty {
    font-size: 0.78rem;
    color: var(--gray-color);
    margin-bottom: 12px;
}

/* ===== 图层列表 ===== */
.layers-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 260px;
    overflow-y: auto;
    padding-right: 4px;
}

.layer-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 2px solid var(--light-gray);
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    transition: var(--transition);
}

.layer-item:hover { border-color: #c7d2fe; }

.layer-item.active {
    border-color: var(--primary-color);
    background: #f5f8ff;
    box-shadow: 0 0 0 2px rgba(67, 97, 238, 0.12);
}

.layer-item.hidden-layer { opacity: 0.55; }

.layer-thumb {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: 8px;
    background: linear-gradient(135deg, #eef2ff, #e0e7ff);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: var(--secondary-color);
}

.layer-meta { flex: 1; min-width: 0; }
.layer-name {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.layer-sub {
    font-size: 0.72rem;
    color: var(--gray-color);
    font-family: 'Consolas', 'Monaco', monospace;
}

.layer-actions { display: flex; align-items: center; gap: 4px; }

.layer-actions button {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 6px;
    background: var(--light-gray);
    color: var(--gray-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    transition: var(--transition);
}
.layer-actions button:hover { background: #d8dee6; color: var(--dark-color); }
.layer-actions button:disabled { opacity: 0.35; cursor: not-allowed; }
.layer-actions .layer-del:hover { background: #ffe0ec; color: var(--danger-color); }
.layer-actions .layer-vis.off { color: #adb5bd; }

/* ===== 配置分组 ===== */
.configuration-section { display: flex; flex-direction: column; }
.configuration-section > h3 { margin-bottom: 14px; }

.config-group {
    margin-bottom: 18px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--light-gray);
}
.config-group:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.config-group h4 {
    color: var(--secondary-color);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
}

.config-row {
    display: grid;
    grid-template-columns: 86px 1fr 56px;
    align-items: center;
    margin-bottom: 13px;
    gap: 14px;
}
.config-row:last-child { margin-bottom: 0; }

.config-row label { font-weight: 500; color: #495057; text-align: left; font-size: 0.9rem; }

.config-row-value {
    grid-column: 3;
    text-align: right;
    font-weight: 600;
    font-family: 'Consolas', 'Monaco', monospace;
    color: var(--primary-color);
    font-size: 0.85rem;
}

.color-picker {
    display: flex;
    align-items: center;
    gap: 12px;
    grid-column: 2 / -1;
}

.color-picker input[type="color"] {
    width: 48px;
    height: 38px;
    border: 2px solid var(--light-gray);
    border-radius: 8px;
    cursor: pointer;
    padding: 0;
}
.color-picker input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-picker input[type="color"]::-webkit-color-swatch { border: none; border-radius: 6px; }
.color-picker span { font-family: 'Consolas','Monaco',monospace; font-size: 0.85rem; color: var(--gray-color); }

.config-row input[type="range"] {
    grid-column: 2;
    height: 8px;
    border-radius: 4px;
    background: var(--light-gray);
    outline: none;
    -webkit-appearance: none;
    width: 100%;
}
.config-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
}
.config-row input[type="range"]::-moz-range-thumb {
    width: 20px; height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
}

.config-row select {
    grid-column: 2 / -1;
    padding: 9px 13px;
    border: 2px solid var(--light-gray);
    border-radius: 8px;
    font-size: 0.95rem;
    transition: var(--transition);
    width: 100%;
}
.config-row select:focus { outline: none; border-color: var(--primary-color); }

/* 旋转/翻转按钮 */
.transform-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.t-btn {
    flex: 1 1 calc(33% - 8px);
    min-width: 96px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 10px;
    border: 2px solid var(--light-gray);
    border-radius: 8px;
    background: #fff;
    color: var(--dark-color);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}
.t-btn:hover { border-color: var(--primary-color); background: #f0f3ff; }
.t-btn.flip-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}
.t-btn-reset { color: var(--danger-color); }
.t-btn-reset:hover { border-color: var(--danger-color); background: #ffe0ec; }

/* 编辑器禁用态（无图层时） */
.configuration-section.disabled { opacity: 0.5; pointer-events: none; }

/* ===== 右侧面板 ===== */
.right-panel h3 { color: var(--primary-color); display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }

.preview-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.preview-box {
    width: 220px;
    height: 220px;
    border-radius: 15px;
    background:
        linear-gradient(45deg, #f0f0f0 25%, transparent 25%),
        linear-gradient(-45deg, #f0f0f0 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #f0f0f0 75%),
        linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    border: 2px dashed var(--light-gray);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}
.preview-box svg { display: block; }

.preview-label { font-size: 0.9rem; color: var(--gray-color); text-align: center; }

/* 输出区域 */
.output-section { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 10px;
}
.code-header h4 { color: var(--secondary-color); display: flex; align-items: center; gap: 10px; }

.copy-buttons { display: flex; gap: 10px; flex-wrap: wrap; }

.copy-btn {
    padding: 8px 14px;
    background-color: var(--light-gray);
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}
.copy-btn:hover { background-color: #d1d5db; }

.code-output {
    width: 100%;
    flex: 1 1 auto;
    min-height: 170px;
    padding: 15px;
    border: 2px solid var(--light-gray);
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 0.82rem;
    line-height: 1.5;
    resize: vertical;
    background-color: #2d2d2d;
    color: #f8f8f2;
    margin-bottom: 12px;
}

.action-buttons { display: flex; gap: 15px; flex-shrink: 0; }

.btn-primary, .btn-secondary {
    flex: 1;
    padding: 12px 18px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.btn-primary { background-color: var(--primary-color); color: white; }
.btn-primary:hover { background-color: var(--secondary-color); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(67, 97, 238, 0.3); }
.btn-secondary { background-color: var(--light-gray); color: var(--dark-color); }
.btn-secondary:hover { background-color: #d1d5db; transform: translateY(-2px); }

/* 页脚 */
.footer {
    text-align: center;
    padding: 20px;
    color: var(--gray-color);
    font-size: 0.9rem;
    border-top: 1px solid var(--light-gray);
    margin-top: 28px;
}
.footer a { color: var(--primary-color); text-decoration: none; }
.footer a:hover { text-decoration: underline; }
.footer-note { margin-top: 8px; font-size: 0.8rem; color: #adb5bd; }

/* Toast通知 */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background-color: var(--primary-color);
    color: white;
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 15px;
    transform: translateY(100px);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    z-index: 1000;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast i { font-size: 1.2rem; }

@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.fa-spin { animation: spin 1s linear infinite; }

/* 响应式：配置行折叠 */
@media (max-width: 768px) {
    .config-row { grid-template-columns: 1fr auto; gap: 8px 10px; }
    .config-row label { grid-column: 1; }
    .config-row-value { grid-column: 2; }
    .config-row input[type="range"] { grid-column: 1 / -1; }
    .color-picker, .config-row select { grid-column: 1 / -1; }
    .action-buttons { flex-direction: column; }
    .t-btn { flex: 1 1 calc(50% - 8px); }
    /* 移动端为单栏，网格用固定高度避免被压缩 */
    .icons-grid { max-height: 60vh; }
}

/* ============================================================
   现代化自定义下拉（分类）
   ============================================================ */
.custom-select { position: relative; flex: 1; min-width: 0; }
/* 在配置行（画布形状）里让自定义下拉占据控件列 */
.config-row .custom-select { grid-column: 2 / -1; }

.cs-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 13px;
    border: 2px solid var(--light-gray);
    border-radius: 10px;
    background: #fff;
    font-size: 0.9rem;
    color: var(--dark-color);
    cursor: pointer;
    transition: var(--transition);
}
.cs-trigger:hover { border-color: #c7d2fe; }
.custom-select.open .cs-trigger {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.12);
}
.cs-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-arrow { font-size: 0.75rem; color: var(--gray-color); transition: transform 0.2s ease; }
.custom-select.open .cs-arrow { transform: rotate(180deg); color: var(--primary-color); }

.cs-panel {
    position: absolute;
    z-index: 50;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--light-gray);
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.14);
    padding: 8px;
    animation: cs-pop 0.14s ease;
}
@keyframes cs-pop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

.cs-search {
    position: relative;
    display: flex;
    align-items: center;
    margin-bottom: 6px;
}
.cs-search i { position: absolute; left: 11px; color: var(--gray-color); font-size: 0.8rem; pointer-events: none; }
.cs-search input {
    width: 100%;
    padding: 8px 12px 8px 32px;
    border: 2px solid var(--light-gray);
    border-radius: 8px;
    font-size: 0.85rem;
}
.cs-search input:focus { outline: none; border-color: var(--primary-color); }

.cs-options { max-height: 280px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.cs-options::-webkit-scrollbar { width: 8px; }
.cs-options::-webkit-scrollbar-thumb { background: var(--gray-color); border-radius: 4px; }

.cs-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.86rem;
    cursor: pointer;
    transition: background 0.15s ease;
    border: none;
    background: none;
    text-align: left;
    width: 100%;
    color: var(--dark-color);
}
.cs-option:hover { background: #f0f3ff; }
.cs-option.active { background: var(--primary-color); color: #fff; }
.cs-option .cs-opt-count { font-size: 0.72rem; opacity: 0.7; font-family: 'Consolas','Monaco',monospace; }
.cs-option.active .cs-opt-count { opacity: 0.9; }
.cs-empty { padding: 16px; text-align: center; color: var(--gray-color); font-size: 0.82rem; }

/* ============================================================
   中国传统色 选取
   ============================================================ */
.cn-color-block, .palette-block { margin-top: 16px; }

.cn-color-head, .palette-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.cn-color-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--secondary-color);
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.cn-color-tools { display: flex; gap: 8px; }

.mini-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 2px solid var(--light-gray);
    border-radius: 8px;
    background: #fff;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--dark-color);
    cursor: pointer;
    transition: var(--transition);
}
.mini-btn:hover { border-color: var(--primary-color); background: #f0f3ff; color: var(--primary-color); }
.mini-btn.active { background: var(--primary-color); border-color: var(--primary-color); color: #fff; }

.cn-color-panel {
    border: 1px solid var(--light-gray);
    border-radius: 12px;
    padding: 10px;
    background: #fcfcfd;
    animation: cs-pop 0.14s ease;
}

.cn-search {
    position: relative;
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}
.cn-search > i { position: absolute; left: 11px; color: var(--gray-color); font-size: 0.8rem; pointer-events: none; }
.cn-search input {
    width: 100%;
    padding: 8px 70px 8px 32px;
    border: 2px solid var(--light-gray);
    border-radius: 8px;
    font-size: 0.85rem;
}
.cn-search input:focus { outline: none; border-color: var(--primary-color); }
.cn-count {
    position: absolute;
    right: 10px;
    font-size: 0.72rem;
    color: var(--gray-color);
    font-family: 'Consolas','Monaco',monospace;
}

.cn-color-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(62px, 1fr));
    gap: 7px;
    max-height: 240px;
    overflow-y: auto;
    padding-right: 4px;
}
.cn-color-grid::-webkit-scrollbar { width: 8px; }
.cn-color-grid::-webkit-scrollbar-thumb { background: var(--gray-color); border-radius: 4px; }

.cn-swatch {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 5px 3px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: none;
    cursor: pointer;
    transition: var(--transition);
}
.cn-swatch:hover { border-color: var(--primary-color); background: #fff; transform: translateY(-2px); }
.cn-chip {
    width: 100%;
    height: 30px;
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}
.cn-name {
    font-size: 0.68rem;
    color: var(--dark-color);
    line-height: 1.15;
    text-align: center;
    word-break: break-all;
}
.cn-empty { grid-column: 1 / -1; padding: 18px; text-align: center; color: var(--gray-color); font-size: 0.82rem; }

/* ============================================================
   配色方案
   ============================================================ */
.palette-modes { display: flex; gap: 6px; flex-wrap: wrap; }
.palette-mode-btn {
    padding: 5px 11px;
    border: 2px solid var(--light-gray);
    border-radius: 20px;
    background: #fff;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--gray-color);
    cursor: pointer;
    transition: var(--transition);
}
.palette-mode-btn:hover { border-color: #c7d2fe; }
.palette-mode-btn.active { background: var(--primary-color); border-color: var(--primary-color); color: #fff; }

.palette-swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.palette-swatch {
    flex: 1 1 0;
    min-width: 34px;
    height: 44px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
    cursor: pointer;
    position: relative;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.palette-swatch:hover { transform: translateY(-3px); box-shadow: 0 6px 14px rgba(0, 0, 0, 0.18); }
.palette-swatch::after {
    content: attr(data-hex);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 6px);
    transform: translateX(-50%);
    background: #2d2d2d;
    color: #fff;
    font-size: 0.68rem;
    font-family: 'Consolas','Monaco',monospace;
    padding: 3px 7px;
    border-radius: 5px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    z-index: 5;
}
.palette-swatch:hover::after { opacity: 1; }

.palette-hint { margin-top: 8px; font-size: 0.72rem; color: var(--gray-color); }
