/* =====================================================
   AI生成CSS代码 - 样式表  (前缀: acg-)
   ===================================================== */

/* ---- CSS 变量 ---- */
:root {
    --acg-primary:        #2563eb;
    --acg-primary-hover:  #1d4ed8;
    --acg-primary-light:  #eff6ff;
    --acg-success:        #059669;
    --acg-warning:        #d97706;
    --acg-danger:         #dc2626;
    --acg-bg:             #f0f5ff;
    --acg-surface:        #ffffff;
    --acg-border:         #dbeafe;
    --acg-text:           #1e293b;
    --acg-text-muted:     #4b6a9b;
    --acg-text-light:     #93aed6;
    --acg-shadow-sm:      0 1px 4px rgba(37,99,235,.10);
    --acg-shadow-md:      0 4px 14px rgba(37,99,235,.13);
    --acg-shadow-lg:      0 8px 28px rgba(37,99,235,.16);
    --acg-radius:         12px;
    --acg-radius-sm:      7px;
    --acg-toolbar-h:      50px;
    --acg-transition:     0.2s ease;

    /* 代码高亮颜色 */
    --code-bg:            #1e293b;
    --code-text:          #e2e8f0;
    --code-comment:       #64748b;
    --code-selector:      #60a5fa;
    --code-property:      #34d399;
    --code-value:         #fbbf24;
    --code-atrule:        #c084fc;
    --code-punct:         #94a3b8;
}

/* 暗色主题 */
.acg-dark {
    --acg-primary:        #60a5fa;
    --acg-primary-hover:  #93c5fd;
    --acg-primary-light:  #0f172a;
    --acg-bg:             #0a1628;
    --acg-surface:        #0f1f3d;
    --acg-border:         #1e3a5f;
    --acg-text:           #e2e8f0;
    --acg-text-muted:     #93aed6;
    --acg-text-light:     #4b6a9b;
    --acg-shadow-sm:      0 1px 4px rgba(0,0,0,.40);
    --acg-shadow-md:      0 4px 14px rgba(0,0,0,.45);
    --acg-shadow-lg:      0 8px 28px rgba(0,0,0,.55);
}

/* 周末暖色主题（周六/周日自动启用） */
.acg-weekend:not(.acg-dark) {
    --acg-primary:        #f59e0b;
    --acg-primary-hover:  #d97706;
    --acg-primary-light:  #fffbeb;
    --acg-bg:             #fffaf0;
    --acg-border:         #fde68a;
    --acg-text-muted:     #92400e;
    --acg-text-light:     #ca8a04;
    --acg-shadow-sm:      0 1px 4px rgba(245,158,11,.10);
    --acg-shadow-md:      0 4px 14px rgba(245,158,11,.13);
    --acg-shadow-lg:      0 8px 28px rgba(245,158,11,.16);
}

.acg-weekend:not(.acg-dark) .acg-btn--primary,
.acg-weekend:not(.acg-dark) .acg-toolbar-btn--ai {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
}

.acg-weekend:not(.acg-dark) .acg-btn--primary:hover,
.acg-weekend:not(.acg-dark) .acg-toolbar-btn--ai:hover {
    background: linear-gradient(135deg, #d97706, #dc2626);
    box-shadow: 0 4px 14px rgba(245,158,11,.40);
}

/* 周末主题下选中卡片/属性输入的光晕同步为暖色 */
.acg-weekend:not(.acg-dark) .acg-type-item input:checked + .acg-type-card,
.acg-weekend:not(.acg-dark) .acg-style-item input:checked + .acg-style-card {
    box-shadow: 0 0 0 2px rgba(245,158,11,.28);
}

.acg-weekend:not(.acg-dark) .acg-textarea:focus {
    border-color: #f59e0b;
    box-shadow: 0 0 0 3px rgba(245,158,11,.16);
}

/* ---- 全局容器 ---- */
.acg-container {
    display: flex;
    flex-direction: column;
    background: var(--acg-bg);
    border-radius: var(--acg-radius);
    overflow: hidden;
    box-shadow: var(--acg-shadow-lg);
    min-height: 660px;
    border: 1px solid var(--acg-border);
    transition: background var(--acg-transition), border-color var(--acg-transition);
}

/* ---- 工具栏 ---- */
.acg-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 12px;
    height: var(--acg-toolbar-h);
    background: var(--acg-surface);
    border-bottom: 1px solid var(--acg-border);
    flex-wrap: wrap;
    min-height: var(--acg-toolbar-h);
    transition: background var(--acg-transition), border-color var(--acg-transition);
}

.toolbar-group          { display: flex; align-items: center; gap: 2px; }
.toolbar-group--right   { margin-left: auto; }

.acg-toolbar-btn {
    padding: 5px 11px;
    border: 1px solid var(--acg-border);
    border-radius: var(--acg-radius-sm);
    background: var(--acg-surface);
    color: var(--acg-text);
    font-size: 13px;
    cursor: pointer;
    transition: all var(--acg-transition);
    white-space: nowrap;
}

.acg-toolbar-btn:hover {
    background: var(--acg-primary-light);
    border-color: var(--acg-primary);
    color: var(--acg-primary);
}

.acg-toolbar-btn--ai {
    background: linear-gradient(135deg, #2563eb, #4f46e5);
    color: #fff;
    border-color: transparent;
    font-weight: 600;
    position: relative;
    overflow: hidden;
}

.acg-toolbar-btn--ai::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 55%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.22), transparent);
    animation: acg-btn-shine 3.5s ease-in-out infinite;
    animation-delay: 1.2s;
}

.acg-toolbar-btn--ai:hover {
    background: linear-gradient(135deg, #1d4ed8, #4338ca);
    color: #fff;
    border-color: transparent;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(37,99,235,.40);
}

/* ---- 主内容三列布局 ---- */
.acg-main-content {
    display: grid;
    grid-template-columns: 210px 340px 1fr;
    min-height: 620px;
    overflow: hidden;
}

/* ---- 历史记录面板 ---- */
.acg-history-panel {
    border-right: 1px solid var(--acg-border);
    display: flex;
    flex-direction: column;
    background: var(--acg-surface);
    overflow: hidden;
    transition: background var(--acg-transition), border-color var(--acg-transition);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px 8px;
    border-bottom: 1px solid var(--acg-border);
    flex-shrink: 0;
}

.panel-header h3 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--acg-text);
}

.history-clear-btn {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid var(--acg-border);
    background: transparent;
    color: var(--acg-text-muted);
    cursor: pointer;
    transition: all var(--acg-transition);
}

.history-clear-btn:hover { border-color: var(--acg-danger); color: var(--acg-danger); }

.history-search        { padding: 8px 10px; flex-shrink: 0; }
.history-search-wrap   { position: relative; }

.history-search-wrap input {
    width: 100%;
    padding: 5px 28px 5px 10px;
    border: 1px solid var(--acg-border);
    border-radius: var(--acg-radius-sm);
    font-size: 12px;
    background: var(--acg-bg);
    color: var(--acg-text);
    box-sizing: border-box;
    outline: none;
    transition: border-color var(--acg-transition);
}

.history-search-wrap input:focus { border-color: var(--acg-primary); }

.history-search-clear {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 11px;
    color: var(--acg-text-light);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
}

.history-search-clear:hover { color: var(--acg-danger); }

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 8px;
    scrollbar-width: thin;
    scrollbar-color: var(--acg-border) transparent;
}

.history-list::-webkit-scrollbar        { width: 4px; }
.history-list::-webkit-scrollbar-thumb  { background: var(--acg-border); border-radius: 4px; }

.history-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 12px;
    color: var(--acg-text-light);
    font-size: 12px;
    text-align: center;
    gap: 6px;
}

.history-empty-icon { font-size: 30px; }
.history-empty-main { font-size: 12px; font-weight: 600; color: var(--acg-text-muted); }
.history-empty-sub  { font-size: 11px; }

.history-item {
    padding: 8px 10px;
    border-radius: var(--acg-radius-sm);
    cursor: pointer;
    border: 1px solid transparent;
    margin-bottom: 4px;
    transition: all var(--acg-transition);
}

.history-item:hover, .history-item.active {
    background: var(--acg-primary-light);
    border-color: var(--acg-primary);
}

.history-item.active { box-shadow: inset 3px 0 0 var(--acg-primary); }

.history-item-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--acg-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 3px;
}

.history-item-meta {
    font-size: 11px;
    color: var(--acg-text-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.history-item-del {
    background: none;
    border: none;
    font-size: 11px;
    color: var(--acg-text-light);
    cursor: pointer;
    padding: 0 2px;
    opacity: 0;
    transition: opacity var(--acg-transition);
}

.history-item:hover .history-item-del { opacity: 1; }
.history-item-del:hover                { color: var(--acg-danger); }

.history-item-badge {
    display: inline-block;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 8px;
    background: var(--acg-primary-light);
    color: var(--acg-primary);
    margin-top: 3px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border: 1px solid var(--acg-border);
}

/* ---- 编辑器面板 ---- */
.acg-editor-panel {
    border-right: 1px solid var(--acg-border);
    display: flex;
    flex-direction: column;
    background: var(--acg-surface);
    overflow: hidden;
    transition: background var(--acg-transition), border-color var(--acg-transition);
}

.editor-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px 8px;
    border-bottom: 1px solid var(--acg-border);
    flex-shrink: 0;
}

.editor-panel-title { font-size: 13px; font-weight: 600; color: var(--acg-text); }
.editor-panel-meta  { font-size: 11px; color: var(--acg-text-light); }

.acg-form {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px;
    scrollbar-width: thin;
    scrollbar-color: var(--acg-border) transparent;
}

.acg-form::-webkit-scrollbar       { width: 4px; }
.acg-form::-webkit-scrollbar-thumb { background: var(--acg-border); border-radius: 4px; }

/* ---- 表单元素 ---- */
.acg-form-group { margin-bottom: 14px; }

.acg-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--acg-text);
    margin-bottom: 5px;
    border-bottom: 1px solid var(--acg-border);
    padding-bottom: 4px;
}

.acg-label-hint  { font-size: 11px; font-weight: 400; color: var(--acg-text-light); }
.required-mark   { color: var(--acg-danger); }

.acg-textarea {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--acg-border);
    border-radius: var(--acg-radius-sm);
    font-size: 13px;
    color: var(--acg-text);
    background: var(--acg-bg);
    box-sizing: border-box;
    outline: none;
    transition: border-color var(--acg-transition), box-shadow var(--acg-transition);
    font-family: inherit;
    resize: vertical;
    min-height: 64px;
}

.acg-textarea:focus {
    border-color: var(--acg-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

.acg-char-counter {
    font-size: 11px;
    color: var(--acg-text-light);
    text-align: right;
    margin-top: 3px;
    transition: color var(--acg-transition);
}

.acg-char-counter.acg-char-warning { color: var(--acg-warning); }
.acg-char-counter.acg-char-danger  { color: var(--acg-danger); font-weight: 600; }

/* ---- 元素类型选择器 ---- */
.acg-type-selector {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.acg-type-item { cursor: pointer; }
.acg-type-item input[type="radio"] { display: none; }

.acg-type-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 7px 4px;
    border: 2px solid var(--acg-border);
    border-radius: var(--acg-radius-sm);
    background: var(--acg-bg);
    text-align: center;
    transition: all var(--acg-transition);
    gap: 3px;
}

.acg-type-item:hover .acg-type-card {
    border-color: var(--acg-primary);
    background: var(--acg-primary-light);
}

.acg-type-item input:checked + .acg-type-card {
    border-color: var(--acg-primary);
    background: var(--acg-primary-light);
    box-shadow: 0 0 0 2px rgba(37,99,235,.18);
}

.type-icon { font-size: 16px; }
.type-name { font-size: 11px; font-weight: 600; color: var(--acg-text); }

/* ---- 风格预设选择器 ---- */
.acg-style-selector {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
}

.acg-style-item { cursor: pointer; }
.acg-style-item input[type="radio"] { display: none; }

.acg-style-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 5px;
    border: 2px solid var(--acg-border);
    border-radius: var(--acg-radius-sm);
    background: var(--acg-bg);
    text-align: center;
    transition: all var(--acg-transition);
    gap: 2px;
}

.acg-style-item:hover .acg-style-card {
    border-color: var(--acg-primary);
    background: var(--acg-primary-light);
}

.acg-style-item input:checked + .acg-style-card {
    border-color: var(--acg-primary);
    background: var(--acg-primary-light);
    box-shadow: 0 0 0 2px rgba(37,99,235,.18);
    transform: scale(1.03);
}

.style-icon { font-size: 16px; }
.style-name { font-size: 11px; font-weight: 600; color: var(--acg-text); }
.style-desc { font-size: 10px; color: var(--acg-text-muted); line-height: 1.3; }

/* ---- 颜色主题选择器 ---- */
.acg-color-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.acg-color-item { cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.acg-color-item input[type="radio"] { display: none; }

.acg-color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 3px solid transparent;
    transition: all var(--acg-transition);
    box-shadow: 0 2px 6px rgba(0,0,0,.15);
}

.acg-color-item:hover .acg-color-swatch,
.acg-color-item input:checked + .acg-color-swatch {
    border-color: var(--acg-text);
    transform: scale(1.15);
    box-shadow: 0 3px 10px rgba(0,0,0,.25);
}

.acg-color-name { font-size: 10px; color: var(--acg-text-muted); white-space: nowrap; }

/* ---- 快捷键提示 ---- */
.shortcut-hint {
    font-size: 0.8em;
    opacity: 0.7;
    color: var(--acg-text-muted);
    white-space: nowrap;
    align-self: center;
}

@media (max-width: 640px) { .shortcut-hint, .acg-shortcut-tip { display: none; } }

.acg-shortcut-tip {
    font-size: 11px;
    color: var(--acg-text-light);
    text-align: center;
    margin-top: 6px;
    padding: 6px;
    border-radius: 4px;
    border-top: 1px dashed var(--acg-border);
}

/* ---- 按钮 ---- */
.acg-form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 6px;
}

.acg-btn {
    padding: 9px 20px;
    border-radius: var(--acg-radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--acg-transition);
    display: flex;
    align-items: center;
    gap: 6px;
}

.acg-btn--primary {
    background: linear-gradient(135deg, #2563eb, #4f46e5);
    color: #fff;
    flex: 1;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.acg-btn--primary::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 55%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.22), transparent);
    animation: acg-btn-shine 3.5s ease-in-out infinite;
}

@keyframes acg-btn-shine {
    0%    { left: -100%; }
    45%   { left: 150%; }
    100%  { left: 150%; }
}

.acg-btn--primary:hover {
    background: linear-gradient(135deg, #1d4ed8, #4338ca);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(37,99,235,.35);
}

.acg-btn--primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.acg-btn--secondary {
    background: var(--acg-bg);
    color: var(--acg-text-muted);
    border: 1px solid var(--acg-border);
}

.acg-btn--secondary:hover {
    border-color: var(--acg-primary);
    color: var(--acg-primary);
}

/* ---- 预览面板 ---- */
.acg-preview-panel {
    display: flex;
    flex-direction: column;
    background: var(--acg-bg);
    overflow: hidden;
    position: relative;
}

.preview-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px 0 0;
    border-bottom: 1px solid var(--acg-border);
    background: var(--acg-surface);
    flex-shrink: 0;
}

/* ---- Tab 标签 ---- */
.preview-tabs {
    display: flex;
    gap: 0;
}

.preview-tab {
    padding: 12px 18px;
    font-size: 13px;
    font-weight: 500;
    color: var(--acg-text-muted);
    border: none;
    background: transparent;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--acg-transition);
    white-space: nowrap;
}

.preview-tab:hover { color: var(--acg-primary); }

.preview-tab.active {
    color: var(--acg-primary);
    border-bottom-color: var(--acg-primary);
    font-weight: 600;
}

.preview-panel-actions { display: flex; gap: 6px; margin-left: auto; }

.preview-action-btn {
    padding: 4px 10px;
    font-size: 12px;
    border: 1px solid var(--acg-border);
    border-radius: 4px;
    background: var(--acg-surface);
    color: var(--acg-text-muted);
    cursor: pointer;
    transition: all var(--acg-transition);
    white-space: nowrap;
}

.preview-action-btn:hover {
    border-color: var(--acg-primary);
    color: var(--acg-primary);
}

/* ---- 代码面板 ---- */
.preview-code-panel {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.code-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 300px;
    color: var(--acg-text-light);
    text-align: center;
    gap: 10px;
}

.code-empty-icon  { font-size: 50px; opacity: 0.65; }
.code-empty-title { font-size: 16px; font-weight: 600; color: var(--acg-text-muted); }
.code-empty-hint  { font-size: 13px; color: var(--acg-text-light); line-height: 1.7; }

/* 浮动动画 */
.acg-float-anim { animation: acg-float 2.8s ease-in-out infinite; }

@keyframes acg-float {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-8px); }
}

.code-block-wrap {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* CSS技术说明 */
.code-explanation {
    padding: 10px 16px;
    background: var(--acg-primary-light);
    border-bottom: 1px solid var(--acg-border);
    font-size: 12px;
    color: var(--acg-primary);
    line-height: 1.6;
    flex-shrink: 0;
}

.code-explanation::before { content: '💡 '; }

/* 代码统计栏 */
.code-stats {
    padding: 5px 16px;
    background: var(--code-bg);
    border-bottom: 1px solid rgba(255,255,255,.06);
    font-size: 11px;
    color: var(--code-comment);
    font-family: 'Fira Code', 'Consolas', monospace;
    letter-spacing: 0.3px;
    flex-shrink: 0;
}

/* 代码块 */
.code-block {
    flex: 1;
    margin: 0;
    padding: 16px;
    background: var(--code-bg);
    color: var(--code-text);
    font-family: 'Fira Code', 'Cascadia Code', 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    line-height: 1.7;
    overflow: auto;
    white-space: pre;
    border: none;
    outline: none;
    tab-size: 2;
    scrollbar-width: thin;
    scrollbar-color: #334155 #1e293b;
}

.code-block::-webkit-scrollbar       { width: 6px; height: 6px; }
.code-block::-webkit-scrollbar-track { background: #1e293b; }
.code-block::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }

/* CSS语法高亮 */
.hl-comment  { color: var(--code-comment); font-style: italic; }
.hl-atrule   { color: var(--code-atrule); font-weight: 600; }
.hl-selector { color: var(--code-selector); font-weight: 600; }
.hl-property { color: var(--code-property); }
.hl-value    { color: var(--code-value); }
.hl-punct    { color: var(--code-punct); }
.hl-string   { color: #f87171; }
.hl-number   { color: #fb923c; }

/* ---- 实时预览 iframe ---- */
.preview-iframe-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.iframe-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 300px;
    color: var(--acg-text-light);
    text-align: center;
    gap: 10px;
}

.preview-iframe {
    flex: 1;
    border: none;
    width: 100%;
    background: #fff;
}

.iframe-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    background: var(--acg-surface);
    border-top: 1px solid var(--acg-border);
    flex-shrink: 0;
}

.iframe-info {
    font-size: 11px;
    color: var(--acg-text-light);
}

.iframe-refresh-btn {
    font-size: 12px;
    padding: 3px 10px;
    border: 1px solid var(--acg-border);
    border-radius: 4px;
    background: var(--acg-surface);
    color: var(--acg-text-muted);
    cursor: pointer;
    transition: all var(--acg-transition);
}

.iframe-refresh-btn:hover {
    border-color: var(--acg-primary);
    color: var(--acg-primary);
}

/* ---- 加载状态 ---- */
.preview-loading {
    position: absolute;
    inset: 0;
    background: rgba(240,245,255,.88);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    z-index: 10;
}

.acg-dark .preview-loading { background: rgba(10,22,40,.88); }

.loading-icon {
    font-size: 40px;
    animation: acg-bounce 1s ease-in-out infinite;
}

@keyframes acg-bounce {
    0%, 100% { transform: scale(1) rotate(-5deg); }
    50%       { transform: scale(1.15) rotate(5deg); }
}

.loading-title { font-size: 15px; font-weight: 600; color: var(--acg-text); }
.loading-hint  { font-size: 12px; color: var(--acg-text-muted); text-align: center; max-width: 260px; }

.acg-loading-dots span {
    animation: acg-dot-flash 1.4s infinite ease-in-out;
    opacity: 0;
}
.acg-loading-dots span:nth-child(1) { animation-delay: 0.0s; }
.acg-loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.acg-loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes acg-dot-flash {
    0%, 60%, 100% { opacity: 0; }
    30%           { opacity: 1; }
}

.cancel-generate-btn {
    padding: 6px 18px;
    border: 1px solid var(--acg-border);
    border-radius: var(--acg-radius-sm);
    background: var(--acg-surface);
    color: var(--acg-text-muted);
    font-size: 13px;
    cursor: pointer;
    transition: all var(--acg-transition);
    margin-top: 4px;
}

.cancel-generate-btn:hover { border-color: var(--acg-danger); color: var(--acg-danger); }

/* ---- Toast 通知 ---- */
.acg-toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 10px 22px;
    border-radius: 24px;
    font-size: 13px;
    font-weight: 500;
    background: #1e293b;
    color: #fff;
    box-shadow: 0 4px 18px rgba(0,0,0,.25);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s ease;
    z-index: 9999;
    white-space: nowrap;
}

.acg-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.acg-toast--success { background: #059669; }
.acg-toast--error   { background: #dc2626; }
.acg-toast--warning { background: #d97706; }

/* ---- 模态框 ---- */
.acg-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.acg-modal.show { opacity: 1; pointer-events: all; }

.acg-modal-content {
    background: var(--acg-surface);
    border-radius: var(--acg-radius);
    box-shadow: var(--acg-shadow-lg);
    width: 90%;
    max-width: 620px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.96);
    transition: transform 0.2s ease;
}

.acg-modal.show .acg-modal-content { transform: scale(1); }

.acg-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--acg-border);
    flex-shrink: 0;
}

.acg-modal-header h3 { margin: 0; font-size: 15px; font-weight: 600; color: var(--acg-text); }

.acg-modal-close {
    background: none;
    border: none;
    font-size: 16px;
    color: var(--acg-text-muted);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all var(--acg-transition);
}

.acg-modal-close:hover { background: var(--acg-primary-light); color: var(--acg-primary); }

.acg-modal-body { flex: 1; overflow-y: auto; padding: 16px 20px; }

.template-modal-hint { font-size: 12px; color: var(--acg-text-muted); margin: 0 0 14px; }

.template-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.template-card {
    padding: 12px 14px;
    border: 1px solid var(--acg-border);
    border-radius: var(--acg-radius-sm);
    cursor: pointer;
    transition: all var(--acg-transition);
    background: var(--acg-bg);
}

.template-card:hover {
    border-color: var(--acg-primary);
    background: var(--acg-primary-light);
    transform: translateY(-1px);
    box-shadow: var(--acg-shadow-sm);
}

.template-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.template-card-icon { font-size: 18px; }
.template-card-name { font-size: 13px; font-weight: 600; color: var(--acg-text); }
.template-card-desc { font-size: 11px; color: var(--acg-text-muted); }
.template-card-type {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 8px;
    background: var(--acg-primary-light);
    color: var(--acg-primary);
    border: 1px solid var(--acg-border);
    margin-left: auto;
}

/* 历史记录总数徽章 */
.history-count-badge {
    display: inline-block;
    margin-left: 5px;
    padding: 0 5px;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    border-radius: 8px;
    background: var(--acg-primary);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    text-align: center;
    vertical-align: middle;
}

/* 代码语言标识栏 */
.code-lang-bar {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 14px;
    background: #16213a;
    border-bottom: 1px solid rgba(255,255,255,.06);
    flex-shrink: 0;
}

.code-lang-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.acg-dot--css  { background: #c084fc; }   /* 紫色匹配 CSS at规则高亮色 */
.acg-dot--html { background: #f97316; }   /* 橙色区分 HTML */

.code-lang-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--code-comment);
    font-family: 'Fira Code', 'Consolas', monospace;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* 全屏 */
.acg-fullscreen {
    position: fixed !important;
    inset: 0 !important;
    z-index: 999 !important;
    border-radius: 0 !important;
    height: 100vh !important;
}

/* ---- 键盘聚焦环 ---- */
.acg-toolbar-btn:focus-visible,
.acg-btn:focus-visible,
.preview-action-btn:focus-visible,
.preview-tab:focus-visible,
.cancel-generate-btn:focus-visible {
    outline: 2px solid var(--acg-primary);
    outline-offset: 2px;
}
