/* =============================================
   对联生成 - couplet_generation.css
   传统中式红金主题：朱红底色、烫金文字、灯笼装饰
   暗黑模式以 body.dark 为父级选择器前缀
   ============================================= */

/* ========== CSS 变量 ========== */
:root {
    --cg-primary:        #c0392b;
    --cg-primary-light:  #e74c3c;
    --cg-gold:           #d4a017;
    --cg-gold-light:     #f0c040;
    --cg-gold-pale:      #fef9e7;
    --cg-bg:             #fdf6ec;
    --cg-panel-bg:       #ffffff;
    --cg-border:         #f5d9b0;
    --cg-text:           #2c1a0e;
    --cg-text-sub:       #7a4a2a;
    --cg-text-muted:     #b07850;
    --cg-scroll-red:     #c0392b;
    --cg-scroll-gold:    #d4a017;
    --cg-tag-bg:         #fef5e7;
    --cg-tag-border:     #f5d9b0;
    --cg-tag-hover-bg:   #fdebd0;
    --cg-shadow:         rgba(192, 57, 43, 0.12);
}

/* ========== 主容器 ========== */
.cg-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
    min-height: 600px;
    background: var(--cg-bg);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 16px var(--cg-shadow);
    transition: all 0.3s ease;
}

/* 全屏模式 */
.cg-container.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9999;
    border-radius: 0;
    margin: 0;
    min-height: unset;
}

/* ========== 顶部工具栏 ========== */
.cg-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    background: linear-gradient(135deg, #8b1a10 0%, #c0392b 55%, #e74c3c 100%);
    color: #fff;
    flex-wrap: wrap;
    gap: 8px;
    box-shadow: 0 2px 12px rgba(139, 26, 16, 0.45);
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

/* 工具栏纹样装饰 */
.cg-toolbar::before {
    content: '福 壽 春 吉 福 壽 春 吉 福 壽';
    position: absolute;
    top: 0; right: 0;
    font-size: 15px;
    color: rgba(212, 160, 23, 0.12);
    letter-spacing: 10px;
    pointer-events: none;
    white-space: nowrap;
    padding: 4px 10px;
}

.toolbar-title {
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.92);
    letter-spacing: 1px;
    margin-right: 6px;
}

.toolbar-group {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
    min-height: 28px;
    position: relative;
    z-index: 1;
}

.toolbar-btn {
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.92);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: #8b1a10;
    transition: all 0.2s;
    white-space: nowrap;
}

.toolbar-btn:hover:not(:disabled) {
    background: #fff;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.18);
}

.toolbar-btn:active:not(:disabled) {
    transform: translateY(0);
}

.toolbar-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* AI生成主按钮 */
.toolbar-btn-primary {
    background: linear-gradient(135deg, #d4a017 0%, #f0c040 100%);
    color: #5a2d0c;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(212, 160, 23, 0.5);
}

.toolbar-btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #e0b020 0%, #f5cc55 100%);
    box-shadow: 0 4px 14px rgba(212, 160, 23, 0.6);
    color: #3d1f05;
}

.toolbar-btn-primary:disabled {
    background: rgba(212, 160, 23, 0.32);
    color: rgba(90, 45, 12, 0.45);
    box-shadow: none;
}

/* 取消按钮 */
.toolbar-btn-cancel {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #fff;
}

.toolbar-btn-cancel:hover:not(:disabled) {
    background: linear-gradient(135deg, #f87171 0%, #ef4444 100%);
    color: #fff;
}

/* ========== 主内容区：三栏 ========== */
.cg-main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    background: var(--cg-bg);
}

/* ========== 左栏：历史记录 ========== */
.cg-history-panel {
    width: 210px;
    flex-shrink: 0;
    background: #fff;
    border-right: 1px solid var(--cg-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.history-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    background: linear-gradient(to bottom, #fdf6ec 0%, #fdebd0 100%);
    border-bottom: 1px solid var(--cg-border);
    flex-shrink: 0;
}

.history-panel-header h3 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--cg-primary);
    border-left: 2px solid var(--cg-gold);
    padding-left: 6px;
}

.history-count {
    font-size: 11px;
    color: var(--cg-text-muted);
    font-weight: 400;
}

.history-clear-btn {
    background: #fff3f0;
    border: none;
    border-radius: 3px;
    color: var(--cg-primary);
    font-size: 11px;
    padding: 3px 7px;
    cursor: pointer;
    transition: background 0.2s;
}

.history-clear-btn:hover {
    background: #fde0da;
}

.history-search {
    padding: 8px 10px;
    border-bottom: 1px solid var(--cg-border);
    flex-shrink: 0;
}

.history-search input {
    width: 100%;
    box-sizing: border-box;
    padding: 5px 8px;
    border: 1px solid var(--cg-border);
    border-radius: 4px;
    font-size: 12px;
    color: var(--cg-text);
    background: #fffdf8;
    outline: none;
    transition: border-color 0.2s;
}

.history-search input:focus {
    border-color: var(--cg-gold);
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px 0;
}

.history-empty {
    padding: 24px 14px;
    text-align: center;
    color: var(--cg-text-muted);
    font-size: 12px;
}

.history-item {
    padding: 10px 14px;
    border-bottom: 1px solid #fef4e8;
    cursor: pointer;
    transition: background 0.15s;
    position: relative;
}

.history-item:hover {
    background: var(--cg-tag-hover-bg);
}

.history-item.active {
    background: #fdebd0;
    border-left: 3px solid var(--cg-primary);
}

.history-item-type {
    font-size: 11px;
    color: var(--cg-primary);
    font-weight: 600;
    margin-bottom: 3px;
}

.history-item-title {
    font-size: 12px;
    color: var(--cg-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 3px;
}

.history-item-meta {
    font-size: 11px;
    color: var(--cg-text-muted);
}

.history-item-delete {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    color: #ccc;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 3px;
    transition: all 0.15s;
    display: none;
}

.history-item:hover .history-item-delete {
    display: block;
}

.history-item-delete:hover {
    color: var(--cg-primary);
    background: #fde0da;
}

/* ========== 中栏：表单输入 ========== */
.cg-input-panel {
    width: 340px;
    flex-shrink: 0;
    background: #fffdf8;
    border-right: 1px solid var(--cg-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    padding: 12px 16px 10px;
    border-bottom: 1px solid var(--cg-border);
    background: linear-gradient(to bottom, #fdf6ec 0%, #fdebd0 100%);
    flex-shrink: 0;
}

.panel-header h3 {
    margin: 0 0 4px;
    font-size: 14px;
    font-weight: 700;
    color: var(--cg-primary);
    border-left: 2px solid var(--cg-gold);
    padding-left: 6px;
}

.panel-tip {
    font-size: 11px;
    color: var(--cg-text-muted);
}

.cg-input-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.form-row {
    display: flex;
    gap: 10px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group-half {
    flex: 1;
    min-width: 0;
}

.form-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--cg-text-sub);
}

.required-mark {
    color: var(--cg-primary);
    font-size: 13px;
    margin-left: 2px;
}

.label-tip {
    font-size: 11px;
    color: var(--cg-text-muted);
    font-weight: 400;
    margin-left: 2px;
}

.cg-select {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--cg-border);
    border-radius: 5px;
    font-size: 12px;
    color: var(--cg-text);
    background: #fffdf8;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23b07850' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
}

.cg-select:focus {
    border-color: var(--cg-gold);
    box-shadow: 0 0 0 2px rgba(212, 160, 23, 0.15);
}

.cg-input {
    width: 100%;
    box-sizing: border-box;
    padding: 7px 10px;
    border: 1px solid var(--cg-border);
    border-radius: 5px;
    font-size: 12px;
    color: var(--cg-text);
    background: #fffdf8;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.cg-input:focus {
    border-color: var(--cg-gold);
    box-shadow: 0 0 0 2px rgba(212, 160, 23, 0.15);
}

.cg-textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 9px 10px;
    border: 1px solid var(--cg-border);
    border-radius: 5px;
    font-size: 13px;
    color: var(--cg-text);
    background: #fffdf8;
    resize: vertical;
    outline: none;
    line-height: 1.6;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
    min-height: 90px;
}

.cg-textarea:focus {
    border-color: var(--cg-gold);
    box-shadow: 0 0 0 2px rgba(212, 160, 23, 0.15);
}

.cg-textarea-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2px;
}

.cg-textarea-hint {
    font-size: 11px;
    color: var(--cg-text-muted);
}

.theme-char-count {
    font-size: 11px;
    color: var(--cg-text-muted);
}

/* 场景标签 */
.tag-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--cg-text-sub);
    margin-bottom: 2px;
}

.scene-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.scene-tag {
    padding: 5px 10px;
    background: var(--cg-tag-bg);
    border: 1px solid var(--cg-tag-border);
    border-radius: 20px;
    font-size: 12px;
    color: var(--cg-text-sub);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.scene-tag:hover {
    background: var(--cg-tag-hover-bg);
    border-color: var(--cg-gold);
    color: var(--cg-primary);
    transform: translateY(-1px);
}

/* shake 动画 */
@keyframes cgShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-5px); }
    40% { transform: translateX(5px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}
.shake { animation: cgShake 0.4s ease; }

/* ========== 右栏：结果展示 ========== */
.cg-result-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--cg-bg);
}

.result-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.result-meta-type {
    font-size: 11px;
    padding: 2px 8px;
    background: #fdebd0;
    color: var(--cg-primary);
    border-radius: 10px;
    font-weight: 600;
}

.result-style-badge {
    font-size: 11px;
    padding: 2px 8px;
    background: #fef9e7;
    color: var(--cg-gold);
    border-radius: 10px;
    border: 1px solid #f5d9b0;
}

.result-time {
    font-size: 11px;
    color: var(--cg-text-muted);
    margin-left: auto;
}

.cg-result-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    scroll-behavior: smooth;
}

/* 初始占位 */
.result-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 300px;
    gap: 10px;
}

.placeholder-lantern {
    font-size: 64px;
    animation: cgLanternSway 3s ease-in-out infinite;
    filter: drop-shadow(0 4px 12px rgba(192, 57, 43, 0.25));
}

@keyframes cgLanternSway {
    0%, 100% { transform: rotate(-5deg); }
    50% { transform: rotate(5deg); }
}

.placeholder-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--cg-text-sub);
    margin: 0;
}

.placeholder-desc {
    font-size: 13px;
    color: var(--cg-text-muted);
    margin: 0;
}

/* 加载中 */
.result-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 300px;
    gap: 14px;
}

.loading-anim {
    display: flex;
    gap: 10px;
}

.loading-char {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--cg-primary) 0%, var(--cg-primary-light) 100%);
    color: #ffd700;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 700;
    animation: cgCharBounce 1.2s ease-in-out infinite;
    box-shadow: 0 4px 10px rgba(192, 57, 43, 0.35);
}

.loading-char:nth-child(2) { animation-delay: 0.2s; }
.loading-char:nth-child(3) { animation-delay: 0.4s; }

@keyframes cgCharBounce {
    0%, 100% { transform: translateY(0); opacity: 1; }
    50% { transform: translateY(-10px); opacity: 0.7; }
}

.loading-dots {
    display: flex;
    gap: 6px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background: var(--cg-gold);
    border-radius: 50%;
    animation: cgDotPulse 1.2s ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes cgDotPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.4); opacity: 0.5; }
}

.loading-text {
    font-size: 14px;
    color: var(--cg-text-sub);
    font-weight: 500;
    letter-spacing: 1px;
}

/* 错误块 */
.result-error-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    height: 100%;
    min-height: 300px;
}

.result-error-icon {
    font-size: 40px;
}

.result-error-msg {
    font-size: 14px;
    color: #d9534f;
    text-align: center;
    max-width: 320px;
    line-height: 1.5;
    margin: 0;
}

.result-error-retry {
    padding: 8px 22px;
    background: linear-gradient(135deg, var(--cg-primary) 0%, var(--cg-primary-light) 100%);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.result-error-retry:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(192, 57, 43, 0.4);
}

/* ========== 对联卡片 ========== */
.result-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.couplet-card {
    background: var(--cg-panel-bg);
    border: 1px solid var(--cg-border);
    border-top: 2px solid var(--cg-gold);   /* 金色顶部装饰线，传统红金配色 */
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 3px 12px rgba(192, 57, 43, 0.08);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

.couplet-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(192, 57, 43, 0.14);
}

/* 卡片编号角标 */
.couplet-card-num {
    position: absolute;
    top: 10px;
    left: 14px;
    font-size: 11px;
    color: rgba(255, 215, 0, 0.82);
    font-weight: 600;
    z-index: 1;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    letter-spacing: 1px;
}

/* 横批区域 */
.couplet-hengpi {
    background: linear-gradient(135deg, #8b1a10 0%, #c0392b 55%, #e74c3c 100%);
    padding: 12px 16px 10px;
    text-align: center;
    position: relative;
}

.hengpi-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
    letter-spacing: 2px;
    display: block;
    margin-bottom: 4px;
}

.hengpi-text {
    font-size: 22px;
    font-weight: 900;
    color: #ffd700;
    letter-spacing: 8px;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.4), 1px 1px 2px rgba(0, 0, 0, 0.5);
    font-family: "STKaiti", "楷体", "KaiTi", serif;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
    padding: 0 8px;
    box-sizing: border-box;
}

/* 对联正文区：左右两栏 */
.couplet-body {
    display: flex;
    align-items: stretch;
    gap: 0;
    padding: 0;
}

.couplet-side {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 18px 12px 14px;
    position: relative;
}

.couplet-side-shang {
    border-right: 1px solid var(--cg-border);
    background: #fffdf8;
}

.couplet-side-xia {
    background: #fffcf5;
}

.couplet-side-label {
    font-size: 11px;
    color: var(--cg-text-muted);
    font-weight: 600;
    letter-spacing: 2px;
    margin-bottom: 10px;
    padding: 2px 8px;
    background: rgba(192, 57, 43, 0.06);
    border-radius: 10px;
}

.couplet-side-text {
    writing-mode: vertical-rl;
    text-orientation: upright;
    font-size: 20px;
    font-weight: 700;
    color: var(--cg-primary);
    letter-spacing: 8px;
    line-height: 1.8;
    font-family: "STKaiti", "楷体", "KaiTi", "STSong", "宋体", serif;
    text-shadow: 1px 1px 0 rgba(192, 57, 43, 0.12);
    min-height: 80px;
}

/* 对联解析区域 */
.couplet-analysis {
    padding: 10px 16px 12px;
    border-top: 1px solid var(--cg-border);
    background: var(--cg-gold-pale);
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.couplet-analysis-icon {
    font-size: 14px;
    flex-shrink: 0;
    margin-top: 1px;
}

.couplet-analysis-text {
    font-size: 12px;
    color: var(--cg-text-sub);
    line-height: 1.6;
    flex: 1;
}

/* 操作栏 */
.couplet-actions {
    padding: 8px 12px;
    border-top: 1px solid var(--cg-border);
    background: #fffdf8;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.couplet-copy-btn {
    padding: 5px 14px;
    background: #fff;
    border: 1px solid var(--cg-border);
    border-radius: 4px;
    font-size: 12px;
    color: var(--cg-text-sub);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.couplet-copy-btn:hover {
    border-color: var(--cg-gold);
    color: var(--cg-primary);
    background: var(--cg-tag-hover-bg);
}

/* 入场动画（使用工具前缀 cg 避免全局冲突） */
@keyframes cgResultEnter {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.result-enter-anim .couplet-card {
    animation: cgResultEnter 0.4s ease both;
}

.result-enter-anim .couplet-card:nth-child(2) { animation-delay: 0.08s; }
.result-enter-anim .couplet-card:nth-child(3) { animation-delay: 0.16s; }
.result-enter-anim .couplet-card:nth-child(4) { animation-delay: 0.24s; }
.result-enter-anim .couplet-card:nth-child(5) { animation-delay: 0.32s; }

/* ========== 示例模态框 ========== */
.cg-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 10000;
}

.cg-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 640px;
    max-width: calc(100vw - 32px);
    max-height: 80vh;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
    z-index: 10001;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.cg-modal-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.cg-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--cg-border);
    flex-shrink: 0;
    background: linear-gradient(to bottom, #fdf6ec 0%, #fdebd0 100%);
}

.cg-modal-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--cg-primary);
}

.cg-modal-close {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: var(--cg-text-muted);
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.cg-modal-close:hover {
    background: #fde0da;
    color: var(--cg-primary);
}

.cg-modal-body {
    padding: 16px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.example-card {
    padding: 14px;
    border: 1px solid var(--cg-border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    background: #fffdf8;
}

.example-card:hover {
    border-color: var(--cg-gold);
    background: var(--cg-tag-hover-bg);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(212, 160, 23, 0.18);
}

.example-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.example-card-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.example-card-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--cg-text);
    flex: 1;
}

.example-card-badge {
    font-size: 11px;
    padding: 1px 7px;
    background: rgba(192, 57, 43, 0.08);
    color: var(--cg-primary);
    border-radius: 10px;
    white-space: nowrap;
}

.example-card-desc {
    font-size: 12px;
    color: var(--cg-text-muted);
    line-height: 1.5;
}

/* ========== Toast 提示 ========== */
.cg-toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(12px);
    background: rgba(30, 20, 10, 0.88);
    color: #fff;
    padding: 9px 20px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    pointer-events: none;
    opacity: 0;
    transition: all 0.3s;
    z-index: 99999;
    white-space: nowrap;
    max-width: calc(100vw - 40px);
}

.cg-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.cg-toast.success { background: rgba(21, 128, 61, 0.9); }
.cg-toast.error   { background: rgba(185, 28, 28, 0.9); }
.cg-toast.info    { background: rgba(30, 20, 10, 0.88); }

/* =============================================
   暗黑模式（以 body.dark 为父级前缀）
   ============================================= */
body.dark {
    --cg-bg:             #1a1008;
    --cg-panel-bg:       #231508;
    --cg-border:         #4a2e14;
    --cg-text:           #f0e0c0;
    --cg-text-sub:       #c09050;
    --cg-text-muted:     #8a6040;
    --cg-tag-bg:         #2a1a08;
    --cg-tag-border:     #4a2e14;
    --cg-tag-hover-bg:   #3a2010;
    --cg-shadow:         rgba(212, 160, 23, 0.08);
    --cg-gold-pale:      #1e1508;
}

body.dark .cg-container {
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.5);
}

body.dark .cg-history-panel {
    background: #1e1208;
}

body.dark .history-panel-header {
    background: linear-gradient(to bottom, #231508 0%, #2a1a08 100%);
}

body.dark .history-search input {
    background: #1a1008;
    color: var(--cg-text);
    border-color: var(--cg-border);
}

body.dark .history-item {
    border-bottom-color: #2e1c0a;
}

body.dark .history-item:hover {
    background: #2a1a08;
}

body.dark .history-item.active {
    background: #321e08;
    border-left-color: var(--cg-primary);
}

body.dark .cg-input-panel {
    background: #1e1208;
}

body.dark .panel-header {
    background: linear-gradient(to bottom, #231508 0%, #2a1a08 100%);
}

body.dark .cg-select {
    background: #1a1008;
    color: var(--cg-text);
    border-color: var(--cg-border);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238a6040' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    color-scheme: dark;
}

/* 暗黑模式：下拉选项必须显式定义背景色与文字色（规范要求） */
body.dark .cg-select option {
    background-color: #1a1008;
    color: var(--cg-text);
}

body.dark .cg-input {
    background: #1a1008;
    color: var(--cg-text);
    border-color: var(--cg-border);
}

body.dark .cg-textarea {
    background: #1a1008;
    color: var(--cg-text);
    border-color: var(--cg-border);
}

body.dark .cg-result-panel {
    background: #1a1008;
}

body.dark .couplet-card {
    background: #231508;
    border-color: var(--cg-border);
    border-top-color: var(--cg-gold);   /* 暗黑模式保留金色顶边装饰 */
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.35);
}

body.dark .couplet-side-shang {
    background: #1e1208;
    border-right-color: var(--cg-border);
}

body.dark .couplet-side-xia {
    background: #1a1008;
}

body.dark .couplet-analysis {
    background: #1e1508;
}

body.dark .couplet-actions {
    background: #1e1208;
    border-top-color: var(--cg-border);
}

body.dark .couplet-copy-btn {
    background: #231508;
    border-color: var(--cg-border);
    color: var(--cg-text-sub);
}

body.dark .couplet-copy-btn:hover {
    border-color: var(--cg-gold);
    background: #2a1a08;
    color: var(--cg-gold-light);
}

body.dark .cg-modal {
    background: #1e1208;
    border: 1px solid var(--cg-border);
}

body.dark .cg-modal-header {
    background: linear-gradient(to bottom, #231508 0%, #2a1a08 100%);
    border-bottom-color: var(--cg-border);
}

body.dark .example-card {
    background: #1a1008;
    border-color: var(--cg-border);
}

body.dark .example-card:hover {
    background: #2a1a08;
}

body.dark .history-clear-btn {
    background: #2a1008;
    color: var(--cg-primary);
}

body.dark .history-clear-btn:hover {
    background: #3a1a10;
}

body.dark .cg-modal-close:hover {
    background: #3a1a10;
}

body.dark .toolbar-btn {
    color: #8b1a10;
}

body.dark .result-meta-type {
    background: #2a1a08;
}

body.dark .result-style-badge {
    background: #1e1508;
    border-color: var(--cg-border);
}

/* 暗黑模式：主按钮禁用态视觉降级（规范：必须明确定义） */
body.dark .toolbar-btn-primary:disabled {
    background: rgba(212, 160, 23, 0.15);
    color: rgba(212, 160, 23, 0.3);
    box-shadow: none;
    cursor: not-allowed;
}

/* 暗黑模式：上/下联标签金色底调 */
body.dark .couplet-side-label {
    background: rgba(212, 160, 23, 0.1);
    color: var(--cg-text-muted);
}

/* 暗黑模式：历史记录删除按钮适配深色背景 */
body.dark .history-item-delete {
    color: #5a3820;
}

body.dark .history-item-delete:hover {
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.15);
}

/* 暗黑模式：输入框 placeholder 可读性 */
body.dark .history-search input::placeholder { color: #5a3820; }
body.dark .cg-input::placeholder            { color: #5a3820; }
body.dark .cg-textarea::placeholder         { color: #5a3820; }

/* ========== 响应式 ========== */

/* 触屏设备：删除按钮强制可见，禁止依赖 hover */
@media (max-width: 768px) {
    .history-item-delete {
        display: block !important;
        opacity: 1 !important;
    }
    /* 复制按钮在触屏设备下强制可见 */
    .couplet-copy-btn {
        opacity: 1 !important;
    }
}

@media (max-width: 900px) {
    .cg-input-panel {
        width: 280px;
    }
}

@media (max-width: 700px) {
    .cg-main-content {
        flex-direction: column;
    }

    .cg-history-panel {
        width: 100%;
        max-height: 180px;
        border-right: none;
        border-bottom: 1px solid var(--cg-border);
    }

    .cg-input-panel {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--cg-border);
        max-height: 55vh;
    }

    .cg-modal-body {
        grid-template-columns: 1fr;
    }

    .couplet-side-text {
        font-size: 16px;
    }
}
