* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    display: flex;
    min-height: 100vh;
}

/* 侧边栏 */
.sidebar {
    width: 280px;
    background-color: #fff;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.history-item {
    padding: 12px;
    margin-bottom: 8px;
    background-color: #f8f9fa;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.history-item:hover {
    background-color: #e9ecef;
}

.history-item.active {
    background-color: #007bff;
    color: #fff;
}

.history-item-title {
    font-weight: 500;
    font-size: 14px;
    margin-bottom: 4px;
}

.history-item-date {
    font-size: 12px;
    opacity: 0.7;
}

.history-item-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 4px;
}

.delete-history-btn {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 14px;
    opacity: 0.6;
}

.delete-history-btn:hover {
    opacity: 1;
}

/* 主内容区 */
.main-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.settings-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 20px;
    gap: 12px;
}

.api-status {
    font-size: 14px;
    padding: 4px 8px;
    border-radius: 4px;
    background-color: #fff3cd;
    color: #856404;
}

.api-status.configured {
    background-color: #d4edda;
    color: #155724;
}

/* 上传区域 */
.upload-area {
    background-color: #fff;
    border: 2px dashed #ccc;
    border-radius: 12px;
    padding: 60px 20px;
    text-align: center;
    transition: border-color 0.2s;
}

.upload-area:hover {
    border-color: #007bff;
}

.upload-content h1 {
    font-size: 28px;
    margin-bottom: 12px;
    color: #222;
}

.upload-content p {
    font-size: 16px;
    color: #666;
    margin-bottom: 32px;
}

.upload-btn {
    display: inline-block;
    padding: 12px 24px;
    background-color: #007bff;
    color: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.2s;
}

.upload-btn:hover {
    background-color: #0056b3;
}

.hint {
    font-size: 14px;
    color: #999;
    margin-top: 16px;
}

/* 播放器 */
.player-container {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

#videoPlayer {
    width: 100%;
    max-height: 500px;
    background-color: #000;
    border-radius: 4px;
}

/* 时间线 */
.timeline-container {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.timeline-container h3 {
    margin-bottom: 8px;
    font-size: 16px;
}

.timeline {
    position: relative;
    height: 40px;
    background-color: #e9ecef;
    border-radius: 20px;
    margin: 20px 0;
    cursor: pointer;
    overflow: visible;
}

.timeline-progress {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background-color: #007bff;
    border-radius: 20px;
    opacity: 0.3;
    width: 0%;
    transition: width 0.1s;
}

.markers-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.timeline-marker {
    position: absolute;
    top: -8px;
    width: 12px;
    height: 56px;
    background-color: #dc3545;
    border-radius: 6px;
    cursor: move;
    transform: translateX(-50%);
    z-index: 10;
}

.timeline-marker:hover {
    background-color: #c82333;
    transform: translateX(-50%) scale(1.2);
}

.current-markers {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

.marker-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background-color: #e7f3ff;
    border: 1px solid #007bff;
    border-radius: 20px;
    font-size: 14px;
}

.marker-tag .remove-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: #007bff;
    line-height: 1;
    padding: 0 0 0 4px;
}

.marker-tag .remove-btn:hover {
    color: #dc3545;
}

/* 分析区域 */
.analysis-area {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.template-selector h3 {
    margin-bottom: 16px;
    font-size: 18px;
}

.template-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.template-card {
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.template-card:hover {
    border-color: #007bff;
    background-color: #f8f9ff;
}

.template-card.selected {
    border-color: #007bff;
    background-color: #e7f3ff;
}

.template-card h4 {
    margin-bottom: 6px;
    font-size: 16px;
    color: #222;
}

.template-card p {
    font-size: 14px;
    color: #666;
}

/* 模板内容 */
.template-content {
    margin-top: 24px;
}

.analysis-section {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.analysis-section:last-child {
    border-bottom: none;
}

.analysis-section h4 {
    font-size: 16px;
    margin-bottom: 8px;
    color: #222;
    display: flex;
    align-items: center;
    gap: 8px;
}

.analysis-section .time-range {
    font-size: 13px;
    color: #666;
    font-weight: normal;
}

.analysis-section textarea {
    width: 100%;
    min-height: 80px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    resize: vertical;
    font-family: inherit;
}

.analysis-section textarea:focus {
    outline: none;
    border-color: #007bff;
}

/* AI分析区域 */
.ai-analysis-section {
    margin-bottom: 24px;
    padding: 16px;
    background-color: #f8f9fa;
    border-radius: 8px;
}

.ai-analysis-section h3 {
    margin-bottom: 12px;
    font-size: 18px;
}

.ai-result {
    margin-top: 16px;
}

.ai-result-content {
    background-color: #fff;
    padding: 16px;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
    white-space: pre-wrap;
    line-height: 1.7;
}

.ai-result-content h1,
.ai-result-content h2,
.ai-result-content h3 {
    margin: 16px 0 8px 0;
}

.ai-result-content p {
    margin-bottom: 12px;
}

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #666;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 12px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 自定义笔记 */
.custom-notes {
    margin-bottom: 24px;
}

.custom-notes h3 {
    margin-bottom: 12px;
    font-size: 18px;
}

.custom-notes textarea {
    width: 100%;
    min-height: 120px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    resize: vertical;
    font-family: inherit;
}

/* 数据统计 */
.stats-summary {
    margin-bottom: 24px;
    padding: 16px;
    background-color: #f8f9fa;
    border-radius: 8px;
}

.stats-summary h3 {
    margin-bottom: 12px;
    font-size: 18px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.stat-item {
    background-color: #fff;
    padding: 12px;
    border-radius: 6px;
    text-align: center;
}

.stat-label {
    font-size: 13px;
    color: #666;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 20px;
    font-weight: 600;
    color: #007bff;
}

/* 操作按钮栏 */
.actions-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

/* 按钮 */
.btn-primary {
    padding: 10px 20px;
    background-color: #007bff;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-primary:hover {
    background-color: #0056b3;
}

.btn-secondary {
    padding: 10px 20px;
    background-color: #6c757d;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-secondary:hover {
    background-color: #545b62;
}

/* 弹窗 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: #fff;
    border-radius: 12px;
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    color: #333;
}

.md-preview-content {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.md-preview-content h1 {
    font-size: 24px;
    margin-bottom: 16px;
}

.md-preview-content h2 {
    font-size: 20px;
    margin: 16px 0 8px 0;
}

.md-preview-content h3 {
    font-size: 18px;
    margin: 12px 0 6px 0;
}

.md-preview-content p {
    margin-bottom: 12px;
}

.md-preview-content ul,
.md-preview-content ol {
    margin: 12px 0 12px 24px;
}

/* 设置表单 */
.settings-form {
    padding: 20px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 14px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #007bff;
}

/* 响应式 */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        max-height: 200px;
    }

    .template-cards {
        grid-template-columns: 1fr;
    }

    .actions-bar {
        flex-direction: column;
    }

    .actions-bar button {
        width: 100%;
    }
}
