:root {
    --bg-primary: #0d0d18;
    --bg-secondary: #151525;
    --bg-tertiary: #1e1e35;
    --bg-card: #1a1a2e;
    --accent: #7c3aed;
    --accent-light: #a78bfa;
    --accent-dark: #5b21b6;
    --accent-glow: rgba(124, 58, 237, 0.3);
    --text-primary: #f0f0f5;
    --text-secondary: #9090a0;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --border-color: #2a2a45;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
    font-size: 14px;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    min-height: 48px;
}

header h1 {
    font-size: 1.1rem;
    background: linear-gradient(135deg, var(--accent-light), var(--success));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    white-space: nowrap;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

#statsInfo {
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    padding: 4px 10px;
    border-radius: 12px;
    white-space: nowrap;
}

.debug-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.debug-btn:hover {
    background: var(--accent);
    color: white;
}

/* Main Content - 核心左右布局 */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    gap: 12px;
    padding: 12px;
}

.left-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 50%;
    min-width: 0;
    flex-shrink: 0;
}

.right-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 50%;
    min-width: 0;
    flex-shrink: 0;
}

/* 输入区 */
.input-section {
    display: flex;
    gap: 10px;
    background: var(--bg-secondary);
    padding: 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

.input-section textarea {
    flex: 1;
    min-height: 100px;
    padding: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    resize: none;
}

.input-section textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.input-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

/* 按钮基础样式 */
button {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

button.primary {
    background: var(--accent);
    color: white;
}

button.primary:hover {
    background: var(--accent-light);
}

button.secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

button.secondary:hover {
    background: var(--border-color);
}

button.tiny {
    padding: 4px 10px;
    font-size: 11px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: 10px;
}

button.tiny:hover {
    background: var(--accent);
    color: white;
}

button.action-btn {
    padding: 4px 10px;
    font-size: 12px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

button.action-btn:hover {
    background: var(--accent);
    color: white;
}

/* Tab面板 */
.tab-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    overflow: hidden;
    min-height: 0;
}

.function-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.func-tab {
    flex: 1;
    padding: 10px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    border-radius: 0;
}

.func-tab.active {
    background: var(--accent);
    color: white;
}

/* 分类面板 */
.category-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 10px;
    gap: 8px;
    overflow: hidden;
    min-height: 0;
}

.category-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    max-height: 80px;
    overflow-y: auto;
    flex-shrink: 0;
}

.category-tab {
    padding: 4px 10px;
    background: var(--bg-card);
    border-radius: 12px;
    font-size: 12px;
    color: var(--text-secondary);
    border: 1px solid transparent;
}

.category-tab:hover {
    border-color: var(--accent);
    color: var(--accent-light);
}

.category-tab.active {
    background: var(--accent);
    color: white;
}

.sub-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex-shrink: 0;
}

.sub-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 6px;
    overflow-y: auto;
    padding: 8px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    align-content: start;
    min-height: 0;
}

.sub-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 12px;
    cursor: pointer;
    border: 1px solid transparent;
}

.sub-item:hover {
    border-color: var(--accent);
}

.sub-item input {
    width: 14px;
    height: 14px;
    accent-color: var(--accent);
    flex-shrink: 0;
}

.sub-item label {
    flex: 1;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* TAG词库面板 */
.tag-library-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 10px;
    gap: 8px;
    overflow: hidden;
    min-height: 0;
}

.tag-lib-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    max-height: 70px;
    overflow-y: auto;
    flex-shrink: 0;
}

.tag-lib-tab {
    padding: 4px 10px;
    background: var(--bg-card);
    border-radius: 12px;
    font-size: 11px;
    color: var(--text-secondary);
}

.tag-lib-tab.active {
    background: var(--accent);
    color: white;
}

.tag-lib-sub-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    max-height: 60px;
    overflow-y: auto;
    flex-shrink: 0;
}

.tag-lib-sub-tab {
    padding: 3px 8px;
    background: var(--bg-tertiary);
    border-radius: 10px;
    font-size: 11px;
    color: var(--text-secondary);
}

.tag-lib-sub-tab.active {
    background: var(--accent-light);
    color: var(--bg-primary);
}

.tag-list-container {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    min-height: 0;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-content: flex-start;
}

.tag-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    background: var(--bg-tertiary);
    border-radius: 14px;
    font-size: 12px;
    cursor: pointer;
    border: 1px solid var(--border-color);
    user-select: none;
}

.tag-item:hover {
    border-color: var(--accent);
}

.tag-item.selected {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.tag-item.selected .en,
.tag-item.selected .zh {
    color: white;
}

.tag-item .en {
    color: var(--accent-light);
}

.tag-item .zh {
    color: var(--text-secondary);
    font-size: 11px;
}

.tag-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding-top: 8px;
    font-size: 12px;
    flex-shrink: 0;
}

/* 右侧输出区 */
.output-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    padding: 12px;
    flex-shrink: 0;
}

.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.output-header h2 {
    font-size: 14px;
    color: var(--accent-light);
}

.output-actions {
    display: flex;
    gap: 6px;
}

.filter-output-area {
    height: 100px;
}

#outputArea {
    width: 100%;
    height: 100%;
    padding: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    resize: none;
}

.options-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 12px;
    padding: 4px 8px;
    background: var(--bg-tertiary);
    border-radius: 6px;
}

.checkbox-label input {
    width: 14px;
    height: 14px;
    accent-color: var(--accent);
}

.mode-switch {
    display: inline-flex;
    background: var(--bg-tertiary);
    padding: 3px;
    border-radius: 6px;
}

.mode-btn {
    padding: 5px 12px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    border-radius: 4px;
}

.mode-btn.active {
    background: var(--accent);
    color: white;
}

/* 分组结果区 */
.grouped-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    padding: 12px;
    overflow: hidden;
    min-height: 0;
}

.grouped-results {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.group-item {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 10px;
    margin-bottom: 8px;
    border-left: 3px solid var(--accent);
}

.group-item h4 {
    font-size: 13px;
    color: var(--accent-light);
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
}

.group-item h4 span {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: normal;
}

.group-item textarea {
    width: 100%;
    min-height: 36px;
    padding: 6px;
    background: var(--bg-primary);
    border: none;
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 12px;
    resize: vertical;
}

.unclassified-area {
    margin-top: 10px;
    padding: 10px;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.unclassified-area h3 {
    font-size: 13px;
    color: var(--warning);
    margin-bottom: 8px;
}

#unclassifiedList {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.unclassified-tag {
    background: var(--warning);
    color: var(--bg-primary);
    padding: 4px 10px;
    border-radius: 10px;
    font-size: 12px;
    cursor: pointer;
    font-weight: 600;
}

.unclassified-tag:hover {
    opacity: 0.85;
}

/* 弹窗 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: var(--radius);
    width: 100%;
    max-width: 360px;
    border: 1px solid var(--border-color);
}

.modal-content h3 {
    margin-bottom: 16px;
    color: var(--accent-light);
    font-size: 16px;
}

.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    color: var(--text-secondary);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
}

.modal-buttons {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.modal-buttons button {
    flex: 1;
}

.admin-log {
    max-height: 80px;
    overflow-y: auto;
    padding: 8px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--success);
    color: white;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 13px;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1001;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* ============== 响应式布局 ============== */
@media (max-width: 900px) {
    .main-content {
        flex-direction: column;
        overflow-y: auto;
        padding: 10px;
        gap: 10px;
    }

    .left-panel,
    .right-panel {
        width: 100%;
        flex-shrink: 0;
    }

    .left-panel {
        max-height: none;
    }

    .tab-panel {
        min-height: 400px;
    }

    .right-panel {
        min-height: 300px;
    }

    .input-section {
        flex-direction: column;
    }

    .input-buttons {
        flex-direction: row;
        justify-content: flex-end;
    }

    .filter-output-area {
        height: 80px;
    }

    .category-tabs,
    .tag-lib-tabs {
        max-height: 100px;
    }

    .sub-grid {
        grid-template-columns: repeat(2, 1fr);
        max-height: 250px;
    }

    .tag-list-container {
        max-height: 300px;
    }

    .grouped-section {
        max-height: 350px;
    }
}

@media (max-width: 480px) {
    header {
        flex-wrap: wrap;
        gap: 8px;
        padding: 8px 12px;
    }

    header h1 {
        font-size: 1rem;
        flex: 1 0 auto;
    }

    .header-info {
        flex: 0 0 auto;
    }

    #statsInfo {
        font-size: 0.7rem;
        padding: 3px 8px;
    }

    .func-tab {
        font-size: 13px;
        padding: 8px;
    }

    .sub-grid {
        grid-template-columns: 1fr 1fr;
    }

    .sub-item,
    .tag-item,
    button {
        min-height: 40px;
    }

    .modal-content {
        margin: 10px;
    }
}

/* 搜索区域 */
.tag-search-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    flex-shrink: 0;
}

.tag-search-area input[type="text"] {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
}

.tag-search-area input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
}

/* 同步进度条 */
.sync-progress {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-secondary);
    padding: 24px 32px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    z-index: 1002;
    min-width: 280px;
    text-align: center;
}

.sync-text {
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.sync-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

.sync-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
    width: 0%;
    transition: width 0.3s ease;
}
