/* =============================================
   标题生成器 - title_generation.css
   主题色：紫罗兰渐变，体现创意与灵感
   三栏布局：历史记录 | 表单输入 | 结果展示
   ============================================= */

/* ========== 主容器 ========== */
.tg-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
    min-height: 600px;
    background: #faf5ff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(109, 40, 217, 0.08);
    transition: all 0.3s ease;
}

/* 全屏模式 */
.tg-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;
}

/* ========== 顶部工具栏 ========== */
.tg-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: linear-gradient(135deg, #6d28d9 0%, #7c3aed 50%, #a855f7 100%);
    color: white;
    flex-wrap: wrap;
    gap: 8px;
    box-shadow: 0 2px 10px rgba(109, 40, 217, 0.35);
    flex-shrink: 0;
}

.tg-toolbar .toolbar-title {
    font-size: 13px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.96);
    letter-spacing: 0.5px;
    margin-right: 8px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.toolbar-group {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
    min-height: 28px;
}

.tg-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: #6d28d9;
    transition: all 0.2s;
    white-space: nowrap;
}

.tg-toolbar-btn:hover:not(:disabled) {
    background: #fff;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
    color: #5b21b6;
}

.tg-toolbar-btn:active:not(:disabled) {
    transform: translateY(0);
}

.tg-toolbar-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* 暗黑模式下工具栏按鈕禁用态（必须显式覆盖） */
body.dark .tg-toolbar-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(221, 214, 254, 0.4);
}

/* 主操作按钮（生成标题） */
.tg-toolbar-btn-primary {
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
    color: #fff !important;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(109, 40, 217, 0.45);
    letter-spacing: 0.3px;
}

.tg-toolbar-btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #a855f7 0%, #7c3aed 100%);
    box-shadow: 0 4px 14px rgba(109, 40, 217, 0.55);
    color: #fff !important;
}

/* ========== Shake 动画（校验错误提示） ========== */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 50%, 90% { transform: translateX(-5px); }
    30%, 70% { transform: translateX(5px); }
}

.tg-input.shake,
.tg-select.shake,
.tg-textarea.shake {
    animation: shake 0.5s ease-in-out;
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12) !important;
}

.tg-field-error {
    display: block;
    font-size: 11px;
    color: #ef4444;
    margin-top: 3px;
    line-height: 1.4;
    animation: fieldErrIn 0.2s ease;
}

@keyframes fieldErrIn {
    from { opacity: 0; transform: translateY(-3px); }
    to   { opacity: 1; transform: translateY(0); }
}

body.dark .tg-field-error { color: #f87171; }

/* ========== 主内容区：三栏 ========== */
.tg-main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    background: #faf5ff;
}

/* ========== 左栏：历史记录 ========== */
.tg-history-panel {
    width: 210px;
    flex-shrink: 0;
    background: #fff;
    border-right: 1px solid #ede9fe;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tg-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    background: linear-gradient(to bottom, #faf5ff 0%, #f5f0ff 100%);
    border-bottom: 1px solid #ede9fe;
    flex-shrink: 0;
}

.tg-history-header h3 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: #5b21b6;
}

.tg-history-count {
    font-size: 11px;
    color: #7c3aed;
    font-weight: 400;
}

.tg-history-clear-btn {
    background: #f5f0ff;
    border: none;
    color: #ef4444;
    font-size: 11px;
    cursor: pointer;
    padding: 2px 7px;
    border-radius: 3px;
    transition: background 0.2s;
    white-space: nowrap;
}

.tg-history-clear-btn:hover { background: #fde8e8; }

.tg-history-search {
    padding: 8px 10px;
    border-bottom: 1px solid #ede9fe;
    flex-shrink: 0;
}

.tg-history-search input {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid #e9d5ff;
    border-radius: 4px;
    font-size: 12px;
    background: #faf5ff;
    color: #374151;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.2s;
}

.tg-history-search input:focus { border-color: #a855f7; }

.tg-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px 0;
}

.tg-history-list::-webkit-scrollbar { width: 4px; }
.tg-history-list::-webkit-scrollbar-track { background: transparent; }
.tg-history-list::-webkit-scrollbar-thumb { background: #c4b5fd; border-radius: 2px; }
.tg-history-list::-webkit-scrollbar-thumb:hover { background: #a78bfa; }

.tg-history-empty {
    text-align: center;
    color: #9ca3af;
    font-size: 12px;
    padding: 20px 10px;
}

.tg-history-item {
    padding: 8px 28px 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f5f0ff;
    transition: background 0.15s;
    position: relative;
}

.tg-history-item:hover { background: #faf5ff; }

.tg-history-item.active { background: #f5f0ff; box-shadow: inset 3px 0 0 #3b82f6; }

.tg-history-item-topic {
    font-size: 12px;
    color: #374151;
    font-weight: 500;
    line-height: 1.4;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    margin-bottom: 4px;
}

.tg-history-item-meta {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: wrap;
}

.tg-history-badge {
    display: inline-block;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 10px;
    background: #ede9fe;
    color: #6d28d9;
    font-weight: 500;
}

.tg-history-time {
    font-size: 10px;
    color: #9ca3af;
}

.tg-history-del-btn {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    border: none;
    border-radius: 3px;
    background: transparent;
    color: #d1d5db;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
    opacity: 0.5;
}

.tg-history-item:hover .tg-history-del-btn {
    opacity: 1;
}

.tg-history-del-btn:hover {
    background: #fee2e2;
    color: #ef4444;
    opacity: 1;
}

/* ========== 中栏：输入面板 ========== */
.tg-input-panel {
    width: 300px;
    flex-shrink: 0;
    background: #fff;
    border-right: 1px solid #ede9fe;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tg-panel-header {
    padding: 12px 16px;
    background: linear-gradient(to bottom, #faf5ff 0%, #f5f0ff 100%);
    border-bottom: 1px solid #ede9fe;
    flex-shrink: 0;
}

.tg-panel-header h3 {
    margin: 0 0 2px;
    font-size: 13px;
    font-weight: 600;
    color: #5b21b6;
}

.tg-panel-tip {
    font-size: 11px;
    color: #9ca3af;
}

.tg-input-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px;
}

.tg-input-body::-webkit-scrollbar { width: 4px; }
.tg-input-body::-webkit-scrollbar-track { background: transparent; }
.tg-input-body::-webkit-scrollbar-thumb { background: #c4b5fd; border-radius: 2px; }
.tg-input-body::-webkit-scrollbar-thumb:hover { background: #a78bfa; }

.tg-form-group {
    margin-bottom: 14px;
}

.tg-form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 5px;
}

.tg-required { color: #ef4444; margin-left: 2px; }

.tg-label-tip {
    font-size: 11px;
    font-weight: 400;
    color: #9ca3af;
}

.tg-input,
.tg-select,
.tg-textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #e9d5ff;
    border-radius: 5px;
    font-size: 13px;
    color: #374151;
    background: #faf5ff;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
}

.tg-input:focus,
.tg-select:focus,
.tg-textarea:focus {
    border-color: #a855f7;
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.1);
    background: #fff;
}

.tg-textarea {
    resize: vertical;
    min-height: 96px;
    line-height: 1.5;
}

.tg-textarea-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
}

.tg-textarea-hint {
    font-size: 11px;
    color: #c4b5fd;
}

.tg-char-count {
    font-size: 11px;
    color: #a78bfa;
    font-weight: 500;
}

.tg-char-count.warning { color: #f59e0b; }

/* 两列表单行 */
.tg-form-row {
    display: flex;
    gap: 10px;
}

.tg-form-half {
    flex: 1;
    min-width: 0;
}

/* 数量控件 */
.tg-count-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tg-count-btn {
    width: 28px;
    height: 28px;
    border: 1px solid #e9d5ff;
    border-radius: 4px;
    background: #faf5ff;
    color: #6d28d9;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    line-height: 1;
    flex-shrink: 0;
}

.tg-count-btn:hover {
    background: #ede9fe;
    border-color: #a855f7;
}

.tg-count-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    background: #f5f0ff;
    border-color: #ede9fe;
    color: #c4b5fd;
}

body.dark .tg-count-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    background: #1a1625;
    border-color: #211d33;
    color: #4c1d95;
}

.tg-count-input {
    width: 54px;
    padding: 6px 8px;
    border: 1px solid #e9d5ff;
    border-radius: 4px;
    font-size: 13px;
    color: #374151;
    background: #faf5ff;
    text-align: center;
    outline: none;
}

.tg-count-input:focus {
    border-color: #a855f7;
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.1);
}

.tg-count-label {
    font-size: 12px;
    color: #6b7280;
}

/* ========== 右栏：结果展示 ========== */
.tg-result-panel {
    flex: 1;
    background: #fff;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.tg-result-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.tg-result-tag {
    background: linear-gradient(135deg, #ede9fe, #ddd6fe);
    color: #6d28d9;
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}

.tg-result-char {
    color: #7c3aed;
    font-weight: 600;
    font-size: 11px;
}

.tg-result-time {
    color: #9ca3af;
    font-size: 11px;
}

.tg-result-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    position: relative;
    display: flex;
    flex-direction: column;
}

.tg-result-body::-webkit-scrollbar { width: 5px; }
.tg-result-body::-webkit-scrollbar-track { background: #faf5ff; }
.tg-result-body::-webkit-scrollbar-thumb { background: #c4b5fd; border-radius: 3px; }
.tg-result-body::-webkit-scrollbar-thumb:hover { background: #a78bfa; }

/* 占位区 */
.tg-result-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 300px;
    padding: 40px 24px;
    text-align: center;
}

.tg-placeholder-icon {
    font-size: 56px;
    margin-bottom: 16px;
    opacity: 0.4;
    filter: grayscale(0.2);
}

.placeholder-title {
    font-size: 16px;
    font-weight: 600;
    color: #6b7280;
    margin: 0 0 8px;
}

.placeholder-desc {
    font-size: 13px;
    color: #9ca3af;
    margin: 0 0 4px;
    line-height: 1.5;
}

/* 加载动画 */
.tg-result-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 300px;
    padding: 40px 24px;
}

.tg-loading-animation {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
}

.tg-loading-bar {
    width: 6px;
    height: 32px;
    background: linear-gradient(to top, #6d28d9, #a855f7);
    border-radius: 3px;
    animation: tgLoadingBounce 1.2s ease-in-out infinite;
}

.tg-loading-bar:nth-child(2) { animation-delay: 0.15s; }
.tg-loading-bar:nth-child(3) { animation-delay: 0.3s; }
.tg-loading-bar:nth-child(4) { animation-delay: 0.45s; }
.tg-loading-bar:nth-child(5) { animation-delay: 0.6s; }

@keyframes tgLoadingBounce {
    0%, 100% { transform: scaleY(0.4); opacity: 0.5; }
    50%       { transform: scaleY(1.0); opacity: 1.0; }
}

.tg-loading-text {
    font-size: 14px;
    font-weight: 600;
    color: #6d28d9;
    margin: 0 0 6px;
    text-align: center;
}

.tg-loading-sub {
    font-size: 12px;
    color: #9ca3af;
    margin: 0;
    text-align: center;
}

/* ========== 标题卡片列表 ========== */
.tg-titles-list {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

@keyframes tgCardIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.tg-title-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    background: #faf5ff;
    border: 1px solid #ede9fe;
    border-radius: 6px;
    transition: all 0.2s;
    animation: tgCardIn 0.3s ease both;
}

.tg-title-card:hover {
    background: #f5f0ff;
    border-color: #c4b5fd;
    box-shadow: 0 2px 6px rgba(109, 40, 217, 0.08);
}

.tg-title-number {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    background: linear-gradient(135deg, #7c3aed, #a855f7);
    color: #fff;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 1px;
}

.tg-title-text {
    flex: 1;
    font-size: 14px;
    color: #1f2937;
    line-height: 1.55;
    word-break: break-all;
}

.tg-title-copy-btn {
    flex-shrink: 0;
    padding: 3px 9px;
    background: #ede9fe;
    border: none;
    border-radius: 4px;
    font-size: 11px;
    color: #6d28d9;
    cursor: pointer;
    transition: all 0.18s;
    white-space: nowrap;
    align-self: flex-start;
    margin-top: 1px;
}

.tg-title-copy-btn:hover {
    background: #ddd6fe;
    color: #5b21b6;
}

.tg-title-copy-btn.copied {
    background: #d1fae5;
    color: #065f46;
}

/* 错误提示卡片（保留备用，当前未使用） */
.tg-result-error {
    margin: 20px 14px;
    padding: 14px 16px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-left: 4px solid #ef4444;
    border-radius: 6px;
    color: #b91c1c;
    font-size: 13px;
    line-height: 1.5;
}

/* ========== 示例模态框 ========== */
.tg-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 10000;
    backdrop-filter: blur(2px);
}

.tg-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10001;
    width: min(680px, 92vw);
    max-height: 78vh;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}

.tg-modal-content { display: flex; flex-direction: column; height: 100%; }

.tg-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    background: linear-gradient(135deg, #6d28d9, #a855f7);
    color: white;
    flex-shrink: 0;
}

.tg-modal-header h3 { margin: 0; font-size: 15px; font-weight: 700; }

.tg-modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 13px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.tg-modal-close:hover { background: rgba(255, 255, 255, 0.35); }

.tg-modal-body {
    padding: 14px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 10px;
}

.tg-modal-body::-webkit-scrollbar { width: 5px; }
.tg-modal-body::-webkit-scrollbar-thumb { background: #c4b5fd; border-radius: 3px; }

/* 示例卡片 */
.tg-example-card {
    padding: 12px 14px;
    background: #faf5ff;
    border: 1px solid #ede9fe;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.tg-example-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(to bottom, #7c3aed, #a855f7);
    border-radius: 4px 0 0 4px;
}

.tg-example-card:hover {
    background: #f5f0ff;
    border-color: #c4b5fd;
    box-shadow: 0 3px 10px rgba(109, 40, 217, 0.1);
    transform: translateY(-1px);
}

.tg-example-icon {
    font-size: 20px;
    margin-bottom: 6px;
}

.tg-example-title {
    font-size: 13px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 4px;
}

.tg-example-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 10px;
    background: #ede9fe;
    color: #6d28d9;
    font-weight: 500;
    margin-bottom: 5px;
}

.tg-example-desc {
    font-size: 11px;
    color: #6b7280;
    line-height: 1.4;
    margin: 0;
}

/* ========== 暗黑模式 ========== */
body.dark .tg-container {
    background: #1a1625;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

body.dark .tg-toolbar {
    background: linear-gradient(135deg, #4c1d95 0%, #5b21b6 50%, #6d28d9 100%);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

body.dark .tg-toolbar-btn {
    background: rgba(255, 255, 255, 0.12);
    color: #ddd6fe;
}

body.dark .tg-toolbar-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
    color: #ede9fe;
}

body.dark .tg-toolbar-btn-primary {
    background: linear-gradient(135deg, #5b21b6 0%, #4c1d95 100%);
    color: #fff !important;
}

body.dark .tg-toolbar-btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #6d28d9 0%, #5b21b6 100%);
}

body.dark .tg-main-content { background: #1a1625; }

body.dark .tg-history-panel {
    background: #1e1a2e;
    border-right-color: #2d2645;
}

body.dark .tg-history-header {
    background: linear-gradient(to bottom, #211d33, #1e1a2e);
    border-bottom-color: #2d2645;
}

body.dark .tg-history-header h3 { color: #c4b5fd; }

body.dark .tg-history-count { color: #a78bfa; }

body.dark .tg-history-clear-btn {
    background: #2d1f3d;
    color: #f87171;
}

body.dark .tg-history-clear-btn:hover { background: #3d2020; }

body.dark .tg-history-search input {
    background: #211d33;
    border-color: #2d2645;
    color: #e5e7eb;
}

body.dark .tg-history-search input:focus { border-color: #7c3aed; }

body.dark .tg-history-list::-webkit-scrollbar-thumb { background: #4c1d95; }
body.dark .tg-history-list::-webkit-scrollbar-thumb:hover { background: #5b21b6; }

body.dark .tg-history-item { border-bottom-color: #2d2645; }
body.dark .tg-history-item:hover { background: #211d33; }
body.dark .tg-history-item.active { background: #2d2645; box-shadow: inset 3px 0 0 #3b82f6; }
body.dark .tg-history-item-topic { color: #e5e7eb; }
body.dark .tg-history-badge { background: #2d2645; color: #c4b5fd; }
body.dark .tg-history-time { color: #6b7280; }
body.dark .tg-history-empty { color: #6b7280; }
body.dark .tg-history-del-btn { color: #4b5563; opacity: 0.6; }
body.dark .tg-history-item:hover .tg-history-del-btn { opacity: 1; }
body.dark .tg-history-del-btn:hover { background: #3d2020; color: #f87171; opacity: 1; }

body.dark .tg-input-panel {
    background: #1e1a2e;
    border-right-color: #2d2645;
}

body.dark .tg-panel-header {
    background: linear-gradient(to bottom, #211d33, #1e1a2e);
    border-bottom-color: #2d2645;
}

body.dark .tg-panel-header h3 { color: #c4b5fd; }
body.dark .tg-panel-tip { color: #6b7280; }

body.dark .tg-input-body::-webkit-scrollbar-thumb { background: #4c1d95; }
body.dark .tg-input-body::-webkit-scrollbar-thumb:hover { background: #5b21b6; }

body.dark .tg-form-group label { color: #d1d5db; }
body.dark .tg-label-tip { color: #6b7280; }

body.dark .tg-input,
body.dark .tg-select,
body.dark .tg-textarea {
    background: #211d33;
    border-color: #2d2645;
    color: #e5e7eb;
}

body.dark .tg-select {
    color-scheme: dark;
}

body.dark .tg-input:focus,
body.dark .tg-select:focus,
body.dark .tg-textarea:focus {
    border-color: #7c3aed;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);
    background: #261e38;
}

body.dark .tg-textarea-hint { color: #4c1d95; }
body.dark .tg-char-count { color: #7c3aed; }
body.dark .tg-char-count.warning { color: #d97706; }

body.dark .tg-count-btn {
    background: #211d33;
    border-color: #2d2645;
    color: #c4b5fd;
}

body.dark .tg-count-btn:hover {
    background: #2d2645;
    border-color: #7c3aed;
}

body.dark .tg-count-input {
    background: #211d33;
    border-color: #2d2645;
    color: #e5e7eb;
}

body.dark .tg-count-input:focus {
    border-color: #7c3aed;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);
}

body.dark .tg-count-label { color: #9ca3af; }

body.dark .tg-result-panel { background: #1e1a2e; }

body.dark .tg-result-panel .tg-panel-header {
    background: linear-gradient(to bottom, #211d33, #1e1a2e);
    border-bottom-color: #2d2645;
}

body.dark .tg-result-panel .tg-panel-header h3 { color: #c4b5fd; }

body.dark .tg-result-body { background: #1e1a2e; }

body.dark .tg-result-body::-webkit-scrollbar-track { background: #1e1a2e; }
body.dark .tg-result-body::-webkit-scrollbar-thumb { background: #4c1d95; }
body.dark .tg-result-body::-webkit-scrollbar-thumb:hover { background: #5b21b6; }

body.dark .placeholder-title { color: #9ca3af; }
body.dark .placeholder-desc { color: #6b7280; }

body.dark .tg-loading-text { color: #c4b5fd; }
body.dark .tg-loading-sub { color: #6b7280; }

body.dark .tg-loading-bar {
    background: linear-gradient(to top, #4c1d95, #7c3aed);
}

body.dark .tg-titles-list { background: #1e1a2e; }

body.dark .tg-title-card {
    background: #211d33;
    border-color: #2d2645;
}

body.dark .tg-title-card:hover {
    background: #261e38;
    border-color: #4c1d95;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

body.dark .tg-title-text { color: #e5e7eb; }

body.dark .tg-title-copy-btn {
    background: #2d2645;
    color: #c4b5fd;
}

body.dark .tg-title-copy-btn:hover {
    background: #3d2f5a;
    color: #ddd6fe;
}

body.dark .tg-title-copy-btn.copied {
    background: #064e3b;
    color: #6ee7b7;
}

body.dark .tg-result-tag { background: #2d2645; color: #c4b5fd; }
body.dark .tg-result-char { color: #a78bfa; }
body.dark .tg-result-time { color: #6b7280; }

body.dark .tg-result-error {
    background: #2d1515;
    border-color: #7f1d1d;
    color: #fca5a5;
}

body.dark .tg-modal {
    background: #1e1a2e;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

body.dark .tg-modal-header {
    background: linear-gradient(135deg, #3b0764, #6d28d9);
}

body.dark .tg-modal-body { background: #1e1a2e; }
body.dark .tg-modal-body::-webkit-scrollbar-thumb { background: #4c1d95; }

body.dark .tg-example-card {
    background: #211d33;
    border-color: #2d2645;
}

body.dark .tg-example-card:hover {
    background: #261e38;
    border-color: #4c1d95;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}

body.dark .tg-example-title { color: #e5e7eb; }
body.dark .tg-example-badge { background: #2d2645; color: #c4b5fd; }
body.dark .tg-example-desc { color: #9ca3af; }

/* 结果区头部布局：flex 横排标题和操作区 */
.tg-result-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.tg-result-panel-header h3 { margin: 0; }

/* 头部右侧操作区 */
.tg-result-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* 换一批按鈕 */
.tg-result-switch-btn {
    padding: 4px 11px;
    background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    box-shadow: 0 1px 5px rgba(109, 40, 217, 0.25);
}

.tg-result-switch-btn:hover {
    background: linear-gradient(135deg, #6d28d9 0%, #7c3aed 100%);
    box-shadow: 0 3px 10px rgba(109, 40, 217, 0.4);
    transform: translateY(-1px);
}

.tg-result-switch-btn:active { transform: translateY(0); }

body.dark .tg-result-switch-btn {
    background: linear-gradient(135deg, #5b21b6 0%, #7c3aed 100%);
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.3);
}

body.dark .tg-result-switch-btn:hover {
    background: linear-gradient(135deg, #4c1d95 0%, #5b21b6 100%);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
}

/* ========== 错误状态（与 placeholder/loading 保持一致） ========== */
.tg-result-error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 300px;
    padding: 40px 24px;
    text-align: center;
}

.tg-error-icon {
    font-size: 52px;
    margin-bottom: 14px;
    opacity: 0.85;
}

.tg-error-title {
    font-size: 16px;
    font-weight: 600;
    color: #dc2626;
    margin: 0 0 8px;
}

.tg-error-desc {
    font-size: 13px;
    color: #9ca3af;
    margin: 0 0 20px;
    line-height: 1.55;
    max-width: 320px;
}

.tg-error-retry-btn {
    padding: 8px 24px;
    background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(109, 40, 217, 0.3);
}

.tg-error-retry-btn:hover {
    background: linear-gradient(135deg, #6d28d9 0%, #7c3aed 100%);
    box-shadow: 0 4px 14px rgba(109, 40, 217, 0.45);
    transform: translateY(-1px);
}

.tg-error-retry-btn:active { transform: translateY(0); }

/* 暗黑模式 - 错误状态 */
body.dark .tg-error-title { color: #f87171; }
body.dark .tg-error-desc  { color: #6b7280; }

body.dark .tg-error-retry-btn {
    background: linear-gradient(135deg, #5b21b6 0%, #7c3aed 100%);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

body.dark .tg-error-retry-btn:hover {
    background: linear-gradient(135deg, #4c1d95 0%, #5b21b6 100%);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}

/* 暗黑模式 - 结果区头部 */
body.dark .tg-result-panel-header h3 { color: #c4b5fd; }


@media (max-width: 900px) {
    .tg-history-panel { display: none; }
    .tg-input-panel { width: 280px; }
}

@media (max-width: 640px) {
    .tg-main-content { flex-direction: column; }

    .tg-input-panel {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #ede9fe;
        max-height: 45vh;
    }

    body.dark .tg-input-panel {
        border-bottom-color: #2d2645;
    }

    .tg-result-panel { min-height: 300px; }

    .tg-form-row { flex-direction: column; gap: 0; }
}
