:root {
    --bg-main: #0d1117;
    --bg-sidebar: #161b22;
    --bg-input: #0d1117;
    --accent: #58a6ff;
    --accent-glow: rgba(88, 166, 255, 0.2);
    --border: #30363d;
    --text-primary: #c9d1d9;
    --text-secondary: #8b949e;
    --danger: #f85149;
    --success: #238636;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

*::-webkit-scrollbar {
    display: none;
}

body {
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    background-color: var(--bg-main);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: grid;
    grid-template-columns: 320px 1fr 320px;
    height: 100vh;
    width: 100vw;
}

.sidebar {
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.board-header {
    height: 50px;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 2px solid var(--border);
    background: rgba(0, 0, 0, 0.2);
    font-weight: bold;
    color: var(--accent);
    flex-shrink: 0;
}

.results-grid {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.main-workspace {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    background: var(--bg-main);
}

.system-header {
    height: 50px;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-sidebar);
    border-bottom: 2px solid var(--border);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-flow {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.message {
    max-width: 90%;
    display: flex;
    flex-direction: column;
}

.message.assistant {
    align-self: flex-start;
}

.message.user {
    align-self: flex-end;
}

.message-content {
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    padding: 12px 16px;
    border-radius: 6px;
    width: fit-content;
    max-width: 100%;
}

.msg-images {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 8px;
}

.msg-images img {
    max-width: 150px;
    max-height: 150px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.message.user .message-content {
    border-color: var(--accent);
    background: rgba(88, 166, 255, 0.05);
}

.input-area {
    padding: 20px;
    background: var(--bg-sidebar);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.preview-strip {
    padding: 10px 0;
    overflow-x: auto;
    width: 100%;
}

.image-preview-list {
    display: flex;
    gap: 12px;
    align-items: center;
}

.image-preview-item {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    border: 1px solid var(--border);
    position: relative;
    flex-shrink: 0;
    overflow: hidden;
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.input-wrapper {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
}

.type-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.type-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
}

.type-btn.active {
    background: var(--accent);
    color: var(--bg-main);
    border-color: var(--accent);
}

#prompt-input {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    resize: none;
    min-height: 60px;
    max-height: 200px;
}

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}

.send-btn {
    background: var(--accent);
    color: var(--bg-main);
    border: none;
    padding: 10px 24px;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
}

.task-prompt {
    display: none;
}

.task-card {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    position: relative;
    animation: slideIn 0.3s ease-out;
}

.task-card:hover {
    border-color: var(--accent);
}

.task-actions {
    position: absolute;
    top: 10px;
    right: 12px;
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 5;
}

.task-card:hover .task-actions {
    opacity: 1;
}

.task-btn {
    background: rgba(48, 54, 61, 0.8);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: all 0.2s;
}

.task-btn:hover {
    background: var(--accent);
    color: var(--bg-main);
    border-color: var(--accent);
}

/* 引用进度条 */
.ref-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 0 0 8px 8px;
    display: none;
    overflow: hidden;
}

.ref-progress-bar {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #4a9eff);
    width: 0%;
    transition: width 0.3s ease;
}

.ref-progress-text {
    position: relative;
    z-index: 1;
    color: var(--text-primary);
    font-size: 0.7rem;
    line-height: 30px;
    text-align: center;
    font-weight: bold;
}

/* 对话中的进度条 */
.chat-progress {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin: 8px 0;
}

.chat-progress-bar {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 0.3s ease;
}

.chat-status {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 5px;
}

/* 角色管理弹窗 */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    animation: fadeIn 0.3s;
}

.modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: var(--bg-sidebar);
    border: 1px solid var(--accent);
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    animation: slideUp 0.3s;
    box-shadow: 0 0 30px var(--accent-glow);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    margin: 0;
    color: var(--accent);
    font-size: 1.2rem;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--danger);
}

.modal-body {
    padding: 20px;
    max-height: calc(80vh - 80px);
    overflow-y: auto;
}

/* 添加角色表单 */
.add-character-form {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    padding: 15px;
    background: var(--bg-input);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.add-character-form input[type="text"] {
    flex: 1;
    min-width: 150px;
    background: var(--bg-main);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 4px;
    font-family: inherit;
}

.add-character-form input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
}

.btn-primary,
.btn-secondary {
    padding: 8px 16px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--accent);
    color: var(--bg-main);
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-main);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--accent);
}

/* 角色列表 */
.character-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
}

.character-card {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    position: relative;
    transition: all 0.2s;
    cursor: pointer;
}

.character-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.character-card img {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: contain;
    background: #000;
    border-radius: 4px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
    cursor: zoom-in;
    transition: transform 0.2s;
}

.character-card img:hover {
    transform: scale(1.02);
}

.char-controls {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 5px;
}

.char-mini-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s;
}

.char-mini-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent);
}

.char-mini-btn.delete:hover {
    background: rgba(255, 0, 0, 0.2);
    border-color: #ff4444;
}

.character-card .char-name {
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: bold;
    margin-bottom: 5px;
}

.character-card .char-delete {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(255, 0, 0, 0.8);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 0.7rem;
    cursor: pointer;
    display: none;
}

.character-card:hover .char-delete {
    display: block;
}

/* @ 提及下拉菜单 */
.mention-dropdown {
    position: absolute;
    background: var(--bg-sidebar);
    border: 1px solid var(--accent);
    border-radius: 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.mention-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.mention-item:hover,
.mention-item.active {
    background: var(--bg-input);
}

.mention-item img {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    margin-right: 10px;
    object-fit: cover;
}

.mention-item .mention-name {
    color: var(--text-primary);
    font-size: 0.9rem;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.image-preview-remove {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(30, 30, 30, 0.8);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    color: #dfdfdf;
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.2s ease, background 0.2s;
    backdrop-filter: blur(4px);
}

.image-preview-item:hover .image-preview-remove {
    opacity: 1;
}

.image-preview-item:hover img {
    filter: brightness(0.6);
}

.image-preview-remove:hover {
    background: rgba(50, 50, 50, 0.95);
    color: #fff;
}

.image-viewer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    cursor: zoom-out;
    padding: 20px;
    backdrop-filter: blur(5px);
}

.image-viewer.active {
    display: flex;
}

.image-viewer img {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 0 50px rgba(0, 0, 0, 1);
    animation: zoomIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes zoomIn {
    from {
        transform: scale(0.85);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.msg-images img {
    cursor: zoom-in;
    transition: transform 0.2s;
}

.msg-images img:hover {
    opacity: 0.9;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.task-info {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
}

.progress-container {
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin: 5px 0;
}

.progress-bar {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 0.3s ease;
}

.result-media {
    width: 100%;
    border-radius: 4px;
    border: 1px solid var(--border);
    margin-top: 5px;
    cursor: pointer;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: blink 2s infinite;
}

@keyframes blink {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }

    100% {
        opacity: 1;
    }
}

.settings-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
}

.settings-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 15px rgba(88, 166, 255, 0.3);
    transform: translateY(-1px);
}

.settings-btn:active {
    transform: translateY(0);
}

.settings-menu {
    position: absolute;
    top: 60px;
    right: 20px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    padding: 15px;
    border-radius: 8px;
    display: none;
    z-index: 100;
}

.settings-menu.active {
    display: block;
}

/* 全局加载动画 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(13, 17, 23, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    flex-direction: column;
    gap: 20px;
    opacity: 1;
    transition: opacity 0.5s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(88, 166, 255, 0.1);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: rotate 1s linear infinite;
}

.loading-text {
    color: var(--accent);
    font-size: 0.85rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-weight: bold;
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}