/* 导航链接 */
.nav-link {
    @apply px-3 py-2 text-sm font-medium text-dark-muted hover:text-dark-text rounded-md hover:bg-dark-border transition;
}

.nav-link-active {
    @apply text-dark-accent bg-dark-accent/10 hover:bg-dark-accent/10;
}

/* Markdown 渲染 */
.md-content h1, .md-content h2, .md-content h3 {
    @apply font-semibold text-dark-text mt-4 mb-2;
}
.md-content h1 { @apply text-xl; }
.md-content h2 { @apply text-lg; }
.md-content h3 { @apply text-base; }
.md-content p { @apply mb-2 leading-relaxed; }
.md-content ul, .md-content ol { @apply ml-5 mb-2; }
.md-content ul { @apply list-disc; }
.md-content ol { @apply list-decimal; }
.md-content li { @apply mb-1; }
.md-content pre {
    @apply bg-dark-bg text-gray-100 rounded-lg p-4 mb-3 overflow-x-auto text-sm border border-dark-border;
}
.md-content code {
    @apply bg-dark-border text-dark-accent px-1 py-0.5 rounded text-sm;
}
.md-content pre code {
    @apply bg-transparent text-gray-100 p-0;
}
.md-content blockquote {
    @apply border-l-4 border-dark-accent/40 pl-4 italic text-dark-muted my-2;
}

/* 淡入动画 */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.animate-fade-in {
    animation: fadeIn 0.3s ease-out;
}

/* 打字光标 */
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}
.typing-cursor::after {
    content: '▊';
    animation: blink 0.8s infinite;
    color: #7c3aed;
}

@keyframes pulse-border {
    0%, 100% { border-color: white; }
    50% { border-color: #3b82f6; }
}

@keyframes count-update {
    0% { transform: scale(1); color: inherit; }
    50% { transform: scale(1.15); color: #3b82f6; }
    100% { transform: scale(1); color: #3b82f6; }
}

.animate-pulse-once {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1);
}

/* 行数限制 */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Agent 状态颜色 */
.agent-status-running { color: #22c55e; }
.agent-status-needs_confirm { color: #eab308; }
.agent-status-completed { color: #3b82f6; }
.agent-status-failed { color: #ef4444; }
.agent-status-pending { color: #6b7280; }

/* Agent 状态面板卡片 */
.agent-task-card {
    @apply bg-dark-bg border border-dark-border rounded-lg p-3;
}
.agent-task-card .agent-name {
    @apply text-sm font-medium text-dark-text;
}
.agent-task-card .agent-instruction {
    @apply text-xs text-dark-muted mt-1;
}
.agent-task-card .agent-output {
    @apply text-xs text-dark-text font-mono mt-2 bg-dark-surface rounded p-2 max-h-32 overflow-y-auto whitespace-pre-wrap break-all;
}

/* 小说工坊 */
.workshop-tab {
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    color: #64748b;
    border-bottom: 2px solid transparent;
    transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.workshop-tab:hover {
    color: #1d4ed8;
    background: #f8fafc;
}

.workshop-tab-active {
    color: #2563eb;
    border-bottom-color: #2563eb;
    background: #eff6ff;
}

.workshop-button,
.workshop-button-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 7px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.workshop-button {
    color: #334155;
    background: #ffffff;
    border: 1px solid #cbd5e1;
}

.workshop-button:hover {
    background: #f8fafc;
}

.workshop-button-primary {
    color: #ffffff;
    background: #2563eb;
    border: 1px solid #2563eb;
}

.workshop-button-primary:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

.workshop-button:disabled,
.workshop-button-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.workshop-textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #ffffff;
    color: #0f172a;
    font-size: 14px;
    line-height: 1.65;
    resize: vertical;
}

.workshop-textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.workbench-sticky-column {
    position: sticky;
    top: 16px;
}

.workbench-scroll-region {
    max-height: min(72vh, 900px);
    overflow-y: auto;
}

.workbench-editor-region {
    min-height: 640px;
}

.workbench-editor-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px;
}

/* 知识库卡片 */
.knowledge-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px 16px;
}

.knowledge-card-disabled {
    opacity: 0.5;
    background: #f8fafc;
}

.knowledge-card-updated {
    animation: pulse-border 1.5s ease-in-out 2;
}

.knowledge-count-updated {
    animation: count-update 0.6s ease-out forwards;
}

/* 知识库子Tab */
.workshop-subtab {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    border-bottom: 2px solid transparent;
    cursor: pointer;
}

.workshop-subtab:hover {
    color: #334155;
}

.workshop-subtab-active {
    color: #2563eb;
    border-bottom-color: #2563eb;
}

/* 启用/禁用开关 */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: #cbd5e1;
    border-radius: 20px;
    cursor: pointer;
    transition: 0.2s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 2px;
    bottom: 2px; /* 修复拼写错误：b m -> bottom */
    background: white;
    border-radius: 50%;
    transition: transform 0.2s; /* 建议明确过渡属性，后续配合 transform 使用 */
}

.toggle-switch input:checked + .toggle-slider {
    background: #2563eb;
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(16px);
}

/* 弹窗 */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 24px;
    width: 90%;
    max-width: 480px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.app-dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.app-dialog-panel {
    width: min(100%, 420px);
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 24px 64px rgba(15, 23, 42, 0.18);
}

.app-dialog-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.app-button-secondary,
.app-button-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 38px;
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.app-button-secondary {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #334155;
}

.app-button-secondary:hover {
    background: #f8fafc;
}

.app-button-danger {
    background: #dc2626;
    border: 1px solid #dc2626;
    color: #ffffff;
}

.app-button-danger:hover {
    background: #b91c1c;
    border-color: #b91c1c;
}

.app-button-secondary:disabled,
.app-button-danger:disabled,
.app-button-busy {
    opacity: 0.6;
    cursor: not-allowed;
}

.app-dialog-overlay[data-busy='true'] .app-dialog-panel {
    box-shadow: 0 24px 64px rgba(15, 23, 42, 0.24);
}

.app-text-button-danger {
    color: #dc2626;
    font-weight: 500;
    transition: color 0.15s ease, opacity 0.15s ease;
}

.app-text-button-danger:hover {
    color: #b91c1c;
}

.app-text-button-danger:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* 人物编辑Tab */
.profile-tab-btn {
    color: #64748b;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-bottom: none;
    cursor: pointer;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.profile-tab-btn:hover {
    color: #334155;
    background: #f1f5f9;
}
.profile-tab-active {
    color: #2563eb;
    background: #ffffff;
    border-color: #cbd5e1;
    border-bottom: 1px solid #fff;
    margin-bottom: -1px;
}

/* 关系图节点 */
.relation-node {
    cursor: pointer;
    transition: fill 0.15s;
}
.relation-node:hover {
    fill: #dbeafe;
}
.relation-edge {
    cursor: pointer;
}
.relation-edge:hover {
    stroke: #2563eb;
}

/* 草稿卡片 */
.draft-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px 16px;
}
.draft-card-character {
    border-left: 3px solid #3b82f6;
}
.draft-card-relation {
    border-left: 3px solid #10b981;
}

/* 工作台输入框 */
.workshop-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 14px;
}

.workshop-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.outline-content-highlight {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.08) 0%, rgba(59, 130, 246, 0.12) 100%);
    transition: background 0.3s ease-out;
}

@media (max-width: 1279px) {
    .workbench-sticky-column {
        position: static;
        top: auto;
    }

    .workbench-scroll-region {
        max-height: none;
    }

    .workbench-editor-region {
        min-height: auto;
    }
}
