/**
 * Simulated Live Class - Styles
 * Mobile-first responsive design
 */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

header {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: white;
    padding: 0.75rem 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

header h1 {
    font-size: 1.15rem;
    margin-bottom: 0;
    font-weight: 600;
    letter-spacing: -0.01em;
}

header h1 a {
    color: white;
    text-decoration: none;
}

header .subtitle {
    font-size: 0.8rem;
    opacity: 0.7;
    margin-top: 0.1rem;
}

@media (min-width: 768px) {
    header {
        padding: 1rem 0;
    }

    header h1 {
        font-size: 1.35rem;
    }

    header .subtitle {
        font-size: 0.85rem;
    }
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-edit-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    transition: background 0.2s;
    white-space: nowrap;
}

.header-edit-btn:hover {
    background: rgba(255, 255, 255, 0.35);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-nav {
    display: flex;
    gap: 1rem;
}

.nav-link {
    color: white;
    text-decoration: none;
    padding: 0.3rem 0.7rem;
    border-radius: 6px;
    opacity: 0.7;
    font-size: 0.85rem;
    transition: opacity 0.2s, background 0.2s;
}

.nav-link:hover {
    opacity: 1;
    background: rgba(255,255,255,0.1);
}

.nav-link.active {
    opacity: 1;
    background: rgba(255,255,255,0.2);
}

main {
    padding: 2rem 0;
    min-height: calc(100vh - 200px);
}

.breadcrumb {
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    color: #666;
}

.breadcrumb a {
    color: #475569;
    text-decoration: none;
    font-weight: 500;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

.courses-section h2 {
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
    color: #333;
}

.course-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

.course-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.3s, box-shadow 0.3s;
    cursor: pointer;
}

.course-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.course-thumbnail {
    width: 100%;
    height: 200px;
    overflow: hidden;
    background: #e0e0e0;
}

.course-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.course-info {
    padding: 1.5rem;
}

.course-name {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
    color: #1e293b;
}

.course-description {
    color: #666;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.course-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: #888;
    font-size: 0.9rem;
}

.video-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.video-card {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    transition: transform 0.2s;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.video-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.video-thumbnail {
    width: 100%;
    height: 150px;
    background: #e0e0e0;
}

.video-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-info {
    padding: 1rem;
}

.video-title {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: #333;
}

.video-duration {
    color: #888;
    font-size: 0.9rem;
}

/* Add Card */
.add-card {
    border: 2px dashed #cbd5e1;
    background: #f8fafc;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.add-card:hover {
    border-color: #475569;
    background: #f1f5f9;
    transform: none;
    box-shadow: none;
}

.add-card-thumbnail {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
}

.add-card-icon {
    font-size: 3rem;
    color: #94a3b8;
    font-weight: 300;
    line-height: 1;
}

.add-card:hover .add-card-icon {
    color: #475569;
}

/* Video Status Badge */
.video-status-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.video-status-badge.processed {
    background: #dcfce7;
    color: #166534;
}

.video-status-badge.unprocessed {
    background: #fef3c7;
    color: #92400e;
}

.video-thumbnail {
    position: relative;
}

/* Delete Button */
.delete-video-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    opacity: 0.5;
    transition: opacity 0.2s, background 0.2s;
    margin-left: auto;
}

.delete-video-btn:hover {
    opacity: 1;
    background: #fee2e2;
}

.video-meta {
    display: flex;
    align-items: center;
}

.video-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.video-player-wrapper {
    background: black;
    border-radius: 8px;
    overflow: hidden;
}

.video-player {
    width: 100%;
    aspect-ratio: 16/9;
}

.video-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    aspect-ratio: 16/9;
    color: #aaa;
    text-align: center;
    padding: 2rem;
}

.video-placeholder p {
    margin: 0.3rem 0;
    font-size: 1.1rem;
}

.video-placeholder .placeholder-hint {
    font-size: 0.9rem;
    color: #777;
}

.chat-container {
    background: #f8f9fa;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    height: 1000px;
}

.chat-header {
    padding: 0.85rem 1rem;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: white;
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: 12px 12px 0 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.clear-chat-btn {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    transition: background 0.2s;
}

.clear-chat-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chat-header::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #6ff7a3;
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(111, 247, 163, 0.5);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: #f8fafc;
}

.chat-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
}

.chat-message.user {
    align-self: flex-end;
}

.chat-message.assistant {
    align-self: flex-start;
}

.message-content {
    padding: 0.7rem 1rem;
    border-radius: 14px;
    word-wrap: break-word;
    font-size: 0.9rem;
    line-height: 1.5;
}

.chat-message.user .message-content {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.assistant .message-content {
    background: #fff;
    color: #333;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}

.message-image {
    max-width: 200px;
    border-radius: 8px;
    margin-top: 0.5rem;
}

.message-timestamp {
    font-size: 0.75rem;
    color: #888;
    margin-top: 0.25rem;
}

.stream-stage {
    display: inline-block;
    color: #475569;
    font-size: 0.9rem;
    animation: pulse-stage 1.5s ease-in-out infinite;
}

@keyframes pulse-stage {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.voice-status {
    padding: 0.6rem 1rem;
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border-left: 3px solid #4caf50;
    border-radius: 8px;
    margin: 0.5rem 0;
    font-size: 0.9rem;
    color: #2e7d32;
    font-weight: 500;
    display: none;
    animation: pulse-stage 1.5s ease-in-out infinite;
}

.rag-source-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px solid #e2e8f0;
}

.rag-source-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.6rem;
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #cbd5e1;
    border-radius: 16px;
    font-size: 0.72rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.rag-source-btn:hover {
    background: #e2e8f0;
    border-color: #475569;
}

.rag-source-btn .rag-time {
    color: #888;
    font-size: 0.68rem;
}

.chat-input-wrapper {
    padding: 0.75rem 1rem;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
}

.chat-input-container {
    display: flex;
    gap: 0;
    align-items: center;
    background: #e2e8f0;
    border-radius: 24px;
    padding: 0.25rem 0.25rem 0.25rem 0.75rem;
}

.chat-input {
    flex: 1;
    padding: 0.6rem 0.25rem;
    border: none;
    background: transparent;
    font-size: 0.92rem;
    resize: none;
    min-height: 38px;
    max-height: 100px;
    outline: none;
    color: #333;
    font-family: inherit;
    line-height: 1.4;
}

.chat-input::placeholder {
    color: #94a3b8;
}

.image-upload-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0.4rem;
    color: #64748b;
    border-radius: 50%;
    transition: color 0.2s, background 0.2s;
    flex-shrink: 0;
}

.image-upload-btn:hover {
    color: #475569;
    background: rgba(71, 85, 105, 0.1);
}

.mic-btn {
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    background: transparent;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-left: 4px;
    transition: all 0.2s ease;
}

.mic-btn:hover {
    color: #475569;
    background: rgba(71, 85, 105, 0.1);
}

.mic-btn.connecting {
    color: #475569;
    background: rgba(71, 85, 105, 0.1);
    animation: voicePulse 1s ease-in-out infinite;
}

.mic-btn.recording {
    color: #fff;
    background: #ff4444;
    animation: voicePulse 1.5s ease-in-out infinite;
}

@keyframes voicePulse {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.08); opacity: 1; }
}

.mic-btn svg {
    width: 18px;
    height: 18px;
}

.mic-btn.recording svg {
    display: none;
}

.mic-btn.recording::after {
    content: '';
    width: 12px;
    height: 12px;
    background: #fff;
    border-radius: 2px;
}

@keyframes pulse-mic {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.08); }
}

.send-btn {
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s, box-shadow 0.2s, opacity 0.2s;
    box-shadow: 0 2px 8px rgba(30, 41, 59, 0.3);
    padding: 0;
}

.send-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 3px 12px rgba(71, 85, 105, 0.45);
}

.send-btn:active {
    transform: scale(0.95);
}

.send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.send-btn svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: white;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.image-preview {
    margin-bottom: 0.5rem;
    position: relative;
    display: inline-block;
}

.image-preview img {
    max-width: 150px;
    border-radius: 8px;
}

.remove-image {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(0,0,0,0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
}

.loading {
    text-align: center;
    padding: 2rem;
    color: #666;
}

.error {
    background: #fee;
    color: #c33;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.no-courses,
.no-videos {
    text-align: center;
    padding: 3rem;
    color: #888;
}

footer {
    background: #1e293b;
    color: rgba(255, 255, 255, 0.6);
    padding: 1.25rem 0;
    text-align: center;
    margin-top: 3rem;
    font-size: 0.8rem;
}

@media (min-width: 768px) {
    .course-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .video-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .video-container {
        flex-direction: row;
        align-items: flex-start;
    }
    
    .video-left-column {
        flex: 1.5;
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        min-width: 0;
        overflow: hidden;
    }
    
    .chat-container {
        flex: 1;
        height: auto;
        min-height: 1000px;
        max-height: 90vh;
        position: sticky;
        top: 1rem;
    }
}

@media (min-width: 1024px) {
    .course-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .video-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}


/* Video Processing Page Styles */
.processing-section {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    transition: box-shadow 0.3s ease;
    animation: section-fade-in 0.5s ease both;
}

.processing-section:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

@keyframes section-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.processing-section:nth-child(1) { animation-delay: 0s; }
.processing-section:nth-child(2) { animation-delay: 0.05s; }
.processing-section:nth-child(3) { animation-delay: 0.1s; }
.processing-section:nth-child(4) { animation-delay: 0.15s; }
.processing-section:nth-child(5) { animation-delay: 0.2s; }

.processing-section h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: #1f2937;
    border-bottom: 2px solid #f3f4f6;
    padding-bottom: 0.6rem;
    letter-spacing: -0.01em;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 0.5rem;
}

.section-header h2 {
    margin-bottom: 0;
    border-bottom: none;
    padding-bottom: 0;
}

.input-group {
    margin-bottom: 1rem;
}

.input-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.3rem;
    color: #555;
}

.input-group input,
.input-group select {
    width: 100%;
    padding: 0.65rem 0.8rem;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
    background: #fafbfc;
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: #475569;
    box-shadow: 0 0 0 3px rgba(71, 85, 105, 0.12);
    background: white;
}

.input-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 768px) {
    .input-row {
        grid-template-columns: 1fr 1fr 150px;
    }
}

.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: background 0.25s ease, transform 0.15s ease, box-shadow 0.25s ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0,0,0,0.1);
}

.btn:active {
    transform: translateY(0);
    box-shadow: none;
}

.btn-primary {
    background: #1e293b;
    color: white;
}

.btn-primary:hover {
    background: #334155;
    box-shadow: 0 4px 12px rgba(30, 41, 59, 0.25);
}

.btn-warning {
    background: #f59e0b;
    color: white;
}

.btn-warning:hover {
    background: #d97706;
}

.btn-small {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    background: #f0f0f0;
    color: #333;
}

.btn-small:hover {
    background: #e0e0e0;
}

.btn-large {
    padding: 0.8rem 2rem;
    font-size: 1.1rem;
    margin-top: 1rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn-secondary {
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    color: #374151;
    border: 1px solid #d1d5db;
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #e5e7eb 0%, #d1d5db 100%);
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

/* Upload Wizard */
.wizard-steps {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.wizard-step {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    transition: opacity 0.4s ease, transform 0.4s ease, box-shadow 0.3s ease;
    animation: wizard-slide-in 0.4s ease both;
}

.wizard-step:nth-child(1) { animation-delay: 0s; }
.wizard-step:nth-child(2) { animation-delay: 0.1s; }
.wizard-step:nth-child(3) { animation-delay: 0.2s; }

@keyframes wizard-slide-in {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.wizard-step:hover {
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.wizard-step-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.9rem 1.2rem;
    background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
    font-weight: 600;
    color: #374151;
    font-size: 0.95rem;
    letter-spacing: 0.01em;
}

.wizard-step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #1e293b;
    color: white;
    font-size: 0.85rem;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(30, 41, 59, 0.25);
    flex-shrink: 0;
}

.wizard-step-body {
    padding: 1.2rem;
}

.wizard-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.wizard-checkboxes label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.95rem;
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.wizard-checkboxes label:hover {
    background: rgba(71, 85, 105, 0.04);
}

.wizard-checkboxes input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #475569;
    cursor: pointer;
}

.upload-area {
    border: 2px dashed #d1d5db;
    border-radius: 12px;
    padding: 2.5rem 2rem;
    text-align: center;
    margin-bottom: 1rem;
    transition: border-color 0.3s ease, background 0.3s ease, transform 0.2s ease;
    position: relative;
    background: #fafbfc;
}

.upload-area:hover {
    border-color: #a5b4fc;
    background: rgba(71, 85, 105, 0.02);
}

.upload-area.drag-over {
    border-color: #475569;
    background: rgba(71, 85, 105, 0.06);
    transform: scale(1.01);
    box-shadow: 0 0 0 4px rgba(71, 85, 105, 0.1);
}

.upload-prompt {
    color: #6b7280;
    margin: 0;
}

.upload-file-name {
    color: #374151;
    font-weight: 500;
    margin: 0;
}

.upload-progress {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-top: 1rem;
}

.upload-progress-track {
    flex: 1;
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
}

#upload-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #1e293b, #475569, #1e293b);
    background-size: 200% 100%;
    border-radius: 4px;
    width: 0%;
    transition: width 0.3s ease;
    animation: progress-shimmer 2s linear infinite;
}

@keyframes progress-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.upload-progress-text {
    font-size: 0.85rem;
    color: #6b7280;
    min-width: 40px;
}

.upload-status {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: #6b7280;
}

/* Content Detection */
.detect-status {
    margin-left: 0.8rem;
    font-size: 0.9rem;
    color: #6b7280;
    transition: color 0.3s;
}

.detect-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.8rem;
    margin-bottom: 1rem;
}

@media (min-width: 768px) {
    .detect-cards {
        grid-template-columns: repeat(5, 1fr);
    }
}

.detect-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: 1.2rem 0.5rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    text-align: center;
    transition: border-color 0.4s ease, background 0.4s ease, transform 0.25s ease, box-shadow 0.3s ease;
    position: relative;
    overflow: hidden;
    cursor: default;
}

.detect-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: #e5e7eb;
    transition: background 0.4s ease;
}

.detect-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.detect-card.found {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.04);
}

.detect-card.found::before {
    background: linear-gradient(90deg, #22c55e, #16a34a);
}

.detect-card.missing {
    border-color: #fca5a5;
    background: rgba(239, 68, 68, 0.02);
}

.detect-card.missing::before {
    background: linear-gradient(90deg, #ef4444, #dc2626);
}

.detect-card.partial {
    border-color: #fbbf24;
    background: rgba(245, 158, 11, 0.03);
}

.detect-card.partial::before {
    background: linear-gradient(90deg, #f59e0b, #d97706);
}

.detect-card-icon {
    font-size: 2rem;
    line-height: 1;
    transition: transform 0.3s ease;
}

.detect-card:hover .detect-card-icon {
    transform: scale(1.1);
}

.detect-card-label {
    font-weight: 600;
    font-size: 0.85rem;
    color: #374151;
    letter-spacing: 0.01em;
}

.detect-card-status {
    font-size: 1.3rem;
    line-height: 1;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.detect-card.found .detect-card-status,
.detect-card.missing .detect-card-status,
.detect-card.partial .detect-card-status {
    animation: status-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes status-pop {
    0% { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.3); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes card-reveal {
    0% { opacity: 0; transform: translateY(8px) scale(0.97); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* Detect button loading state */
#detect-btn {
    position: relative;
    min-width: 200px;
    transition: all 0.25s ease;
}

#detect-btn:disabled {
    opacity: 0.8;
    cursor: wait;
}

/* Upload section reveal */
#upload-section {
    animation: wizard-slide-in 0.3s ease both;
}

.detect-card-detail {
    font-size: 0.72rem;
    color: #9ca3af;
    min-height: 1rem;
    font-weight: 500;
}

.detect-card.found .detect-card-detail {
    color: #16a34a;
}

.detect-card.partial .detect-card-detail {
    color: #d97706;
}

.detect-card.missing .detect-card-detail {
    color: #dc2626;
}

.detect-card-detail2 {
    font-size: 0.68rem;
    color: #6b7280;
    margin-top: 0.15rem;
    line-height: 1.25;
    min-height: 0.9rem;
}

/* Regenerate divider + counts strip (inside Segments section) */
.regen-divider {
    border: none;
    border-top: 1px solid #e5e7eb;
    margin: 1.5rem 0 1rem;
}

.regen-counts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.6rem;
    margin: 0.75rem 0 1.25rem;
}

.count-item {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.55rem 0.7rem;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #f9fafb;
}

.count-item .count-label {
    font-size: 0.72rem;
    color: #6b7280;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.count-item .count-value {
    font-size: 0.9rem;
    font-weight: 700;
    color: #374151;
}

.count-item .count-value::before {
    content: attr(data-icon) " ";
}

.count-item.complete { border-color: #86efac; background: #f0fdf4; }
.count-item.complete .count-value { color: #16a34a; }
.count-item.partial { border-color: #fcd34d; background: #fffbeb; }
.count-item.partial .count-value { color: #d97706; }
.count-item.missing { border-color: #fecaca; background: #fef2f2; }
.count-item.missing .count-value { color: #dc2626; }
.count-item.pending .count-value { color: #9ca3af; }

.regen-lang-hint {
    font-size: 0.82rem;
    color: #6b7280;
    margin: 0.5rem 0 0.75rem;
}

.modal-lang-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
    padding: 0.2rem 0.6rem;
    background: #f3f4f6;
    border-radius: 6px;
}

.summary-fallback-note {
    background: #fffbeb;
    border: 1px solid #fcd34d;
    color: #92400e;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

/* Input Type Selector */
.upload-section-label {
    font-size: 0.95rem;
    color: #374151;
    margin-bottom: 0.6rem;
    font-weight: 600;
    padding-top: 0.8rem;
    border-top: 1px solid #f3f4f6;
}

.input-type-selector {
    display: flex;
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.input-type-btn {
    padding: 0.65rem 1.2rem;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    background: white;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

.input-type-btn::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: #475569;
    transform: scaleX(0);
    transition: transform 0.25s ease;
}

.input-type-btn:hover {
    border-color: #a5b4fc;
    background: rgba(71, 85, 105, 0.03);
}

.input-type-btn.selected {
    border-color: #475569;
    background: rgba(71, 85, 105, 0.06);
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(71, 85, 105, 0.15);
}

.input-type-btn.selected::after {
    transform: scaleX(1);
}

.input-type-btn.disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

.source-toggle {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1rem;
    padding: 0.6rem 0;
}

.source-toggle label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: #4b5563;
    transition: color 0.2s;
}

.source-toggle label:hover {
    color: #111827;
}

.step-hint {
    font-size: 0.88rem;
    color: #6b7280;
    margin-bottom: 0.8rem;
    padding: 0.5rem 0.75rem;
    background: #f9fafb;
    border-radius: 6px;
    border-left: 3px solid #475569;
}

/* Status Grid */
.status-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.8rem;
}

@media (min-width: 768px) {
    .status-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 1024px) {
    .status-grid {
        grid-template-columns: repeat(8, 1fr);
    }
}

.status-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    padding: 0.7rem;
    background: #f8f9fa;
    border-radius: 10px;
    font-size: 0.9rem;
    text-align: center;
    transition: background 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
    cursor: default;
}

.status-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.status-item.complete {
    background: linear-gradient(135deg, #ecfdf5, #d1fae5);
}

.status-item.partial {
    background: linear-gradient(135deg, #fffbeb, #fef3c7);
}

.status-item.missing {
    background: linear-gradient(135deg, #fef2f2, #fecaca);
}

.status-icon {
    font-size: 1.2rem;
}

.status-label {
    font-weight: 500;
}

.status-detail {
    font-size: 0.75rem;
    color: #666;
    white-space: nowrap;
}

/* Segments Table */
.segment-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.segments-table-wrapper {
    overflow-x: auto;
}

.segments-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.segments-table th,
.segments-table td {
    padding: 0.6rem;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.segments-table th {
    background: #f5f5f5;
    font-weight: 600;
}

.segments-table tr:hover {
    background: #fafafa;
}

.topic-cell {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.status-icons {
    font-size: 0.85rem;
    letter-spacing: 2px;
    display: flex;
    gap: 3px;
}

.status-badge {
    display: inline-block;
    width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-badge.done {
    background: #4caf50;
    color: white;
}

.status-badge.pending {
    background: #e0e0e0;
    color: #666;
}

.legend {
    margin-top: 0.8rem;
    font-size: 0.8rem;
    color: #666;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: 0.5rem;
}

.legend-item .status-badge {
    width: 16px;
    height: 16px;
    line-height: 16px;
    font-size: 0.65rem;
}

/* Regenerate Section */
.dependency-info {
    margin-bottom: 1.5rem;
}

.dependency-info summary {
    cursor: pointer;
    color: #475569;
    font-weight: 500;
}

.dependency-map {
    margin-top: 0.5rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 6px;
    font-size: 0.85rem;
}

.dep-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0;
    border-bottom: 1px solid #eee;
}

.dep-row:last-child {
    border-bottom: none;
}

.dep-step {
    font-weight: 600;
    color: #333;
    min-width: 100px;
}

.dep-arrow {
    color: #999;
}

.dep-requires {
    color: #666;
}

.regen-step {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: #fafafa;
    border-radius: 6px;
    border-left: 3px solid #475569;
}

.regen-step h4 {
    margin-bottom: 0.3rem;
    color: #333;
}

.step-desc {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 0.8rem;
}

.regenerate-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}

.regenerate-checkboxes label {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
}

.quick-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

/* Progress Log */
.progress-log {
    background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
    color: #d4d4d4;
    padding: 1rem;
    border-radius: 10px;
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 0.82rem;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid rgba(71, 85, 105, 0.15);
}

.log-entry {
    margin-bottom: 0.3rem;
    padding: 0.15rem 0;
    animation: log-fade-in 0.3s ease;
    border-left: 2px solid transparent;
    padding-left: 0.5rem;
}

.log-entry:last-child {
    border-left-color: #475569;
}

@keyframes log-fade-in {
    from { opacity: 0; transform: translateX(-8px); }
    to { opacity: 1; transform: translateX(0); }
}

.log-error {
    color: #f48771;
    border-left-color: #f48771 !important;
}

.log-success {
    color: #89d185;
}

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

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

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

.modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
}

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

.modal-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
    padding: 0 1rem;
    background: #fafafa;
}

.modal-tabs {
    display: flex;
    gap: 0;
}

.tab-btn {
    padding: 0.8rem 1.2rem;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.9rem;
    color: #666;
    border-bottom: 2px solid transparent;
}

.tab-btn:hover {
    color: #333;
    background: #f5f5f5;
}

.tab-btn.active {
    color: #475569;
    border-bottom-color: #475569;
}

.lang-toggle {
    display: flex;
    background: #e8e8e8;
    border-radius: 6px;
    padding: 2px;
    margin-right: 0.5rem;
}

.lang-btn {
    padding: 0.3rem 0.7rem;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    color: #888;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.lang-btn:hover {
    color: #555;
}

.lang-btn.active {
    background: #fff;
    color: #475569;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.content-lang-pill {
    padding: 0.25rem 0.75rem;
    border: 1.5px solid #d1d5db;
    background: #f9fafb;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    color: #6b7280;
    border-radius: 20px;
    transition: all 0.15s ease;
}

.content-lang-pill:hover {
    border-color: #9ca3af;
    color: #374151;
}

.content-lang-pill.active {
    background: #3b82f6;
    border-color: #3b82f6;
    color: #fff;
}

.content-lang-pill.has-content {
    border-color: #10b981;
    color: #065f46;
    background: #ecfdf5;
}

.content-lang-pill.has-content.active {
    background: #10b981;
    border-color: #10b981;
    color: #fff;
}

.content-lang-pill:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    background: #f3f4f6;
    border-color: #e5e7eb;
    color: #9ca3af;
}

.content-lang-pill:disabled:hover {
    border-color: #e5e7eb;
    color: #9ca3af;
}

.lang-state-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 0.75rem 0;
    padding: 0.6rem 0.9rem;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
    font-size: 0.85rem;
    color: #92400e;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.mermaid-container {
    overflow-x: auto;
    padding: 1rem;
    background: #fff;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.mermaid-container svg {
    max-width: 100%;
    height: auto;
}

.tab-content pre.mermaid {
    background: transparent;
    padding: 0;
    border: none;
    overflow: visible;
    white-space: pre-wrap;
}

.tab-content pre {
    background: #f5f5f5;
    padding: 1rem;
    border-radius: 6px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 0.9rem;
}

.tab-content h4 {
    margin: 1rem 0 0.5rem;
    color: #333;
}

.tab-content ul,
.tab-content ol {
    margin-left: 1.5rem;
}

.tab-content li {
    margin-bottom: 0.3rem;
}

.vector-content {
    white-space: pre-wrap;
    max-height: 400px;
    overflow-y: auto;
}

.vector-attrs {
    width: 100%;
    border-collapse: collapse;
    margin: 0.5rem 0;
}

.vector-attrs td {
    padding: 0.4rem 0.8rem;
    border-bottom: 1px solid #eee;
    font-size: 0.9rem;
}

.vector-attrs td:first-child {
    width: 140px;
    color: #555;
}

.vector-dims {
    margin-top: 0.8rem;
    color: #888;
    font-size: 0.85rem;
}

.vector-loading {
    color: #888;
    padding: 2rem;
    text-align: center;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #eee;
    text-align: right;
}

/* ===== Segment Edit Mode ===== */

.tab-edit-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.25rem;
}

.edit-pencil-btn {
    background: none;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.15s;
}

.edit-pencil-btn:hover {
    background: #f0f0f0;
}

.edit-textarea {
    width: 100%;
    min-height: 200px;
    padding: 0.75rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    resize: vertical;
    box-sizing: border-box;
}

.edit-textarea:focus {
    outline: none;
    border-color: #475569;
    box-shadow: 0 0 0 2px rgba(71, 85, 105, 0.15);
}

.edit-list {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0;
}

.edit-list-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.edit-list-input {
    flex: 1;
    padding: 0.4rem 0.6rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.85rem;
}

.edit-list-input:focus {
    outline: none;
    border-color: #475569;
}

.edit-remove-item {
    background: none;
    border: none;
    color: #e74c3c;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0 0.3rem;
    line-height: 1;
}

.edit-remove-item:hover {
    color: #c0392b;
}

.edit-add-item-btn {
    margin-top: 0.25rem;
    background: #f8f9fa;
    border: 1px dashed #ccc;
    color: #555;
}

.edit-add-item-btn:hover {
    background: #e9ecef;
}

.edit-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid #eee;
}

.edit-save-btn {
    background: #27ae60;
    color: white;
}

.edit-save-btn:hover {
    background: #219a52;
}

.edit-save-btn:disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

.edit-cancel-btn {
    background: #eee;
    color: #333;
}

.edit-cancel-btn:hover {
    background: #ddd;
}


/* ===== Segment Details Panel ===== */

.segment-panel {
    margin-top: 0.5rem;
    min-width: 0;
    overflow: hidden;
}

/* Seekbar */
.segment-seekbar {
    position: relative;
    padding: 0.75rem 0 1.5rem;
    cursor: pointer;
}

.seekbar-track {
    position: relative;
    height: 14px;
    background: #e2e8f0;
    border-radius: 7px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.08);
}

.seekbar-segment {
    position: absolute;
    top: 0;
    height: 100%;
    opacity: 0.75;
    transition: opacity 0.2s, transform 0.15s;
    border-right: 1.5px solid rgba(255,255,255,0.6);
}

.seekbar-segment:hover {
    opacity: 1;
    transform: scaleY(1.15);
}

.seekbar-segment.active {
    opacity: 1;
    box-shadow: 0 0 0 2px #333;
    z-index: 1;
    border-radius: 2px;
}

.seekbar-playhead {
    position: absolute;
    top: 0.75rem;
    width: 3px;
    height: 14px;
    background: #333;
    border-radius: 2px;
    z-index: 2;
    pointer-events: none;
    transition: left 0.1s linear;
}

.seekbar-tooltip {
    display: none;
    position: absolute;
    top: -2rem;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    pointer-events: none;
    z-index: 3;
}

.seekbar-times {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: #888;
    margin-top: 0.25rem;
}

/* Segment Card — wraps info bar, tabs, content, and nav */
.segment-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(71, 85, 105, 0.08);
    overflow: hidden;
    max-width: 100%;
}

/* Segment Tab Bar */
.segment-tab-bar {
    display: flex;
    align-items: stretch;
    border-bottom: 2px solid #e2e8f0;
    background: #f8fafc;
    position: relative;
    max-width: 100%;
}

.seg-arrow {
    flex-shrink: 0;
    width: 36px;
    border: none;
    background: #f1f5f9;
    color: #475569;
    font-size: 1.3rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    user-select: none;
    z-index: 1;
}

.seg-arrow:hover:not(:disabled) {
    background: #475569;
    color: #fff;
}

.seg-arrow:disabled {
    color: #ccc;
    cursor: default;
    background: #f5f4f8;
}

.seg-tab-scroll {
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-behavior: smooth;
}

.seg-tab-scroll::-webkit-scrollbar {
    display: none;
}

.seg-tab-list {
    display: inline-flex;
    gap: 0;
    white-space: nowrap;
}

.seg-tab {
    padding: 0.65rem 1.1rem;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.84rem;
    color: #777;
    font-weight: 500;
    border-bottom: 2.5px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.2s, background 0.15s;
    white-space: nowrap;
    position: relative;
}

.seg-tab:hover {
    color: #444;
    background: rgba(71, 85, 105, 0.04);
}

.seg-tab.active {
    color: #475569;
    border-bottom-color: #475569;
    background: #fff;
}

/* Content Area */
.segment-content-area {
    background: #fff;
}

.segment-view {
    display: none;
}

.segment-view.active {
    display: block;
}

.view-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    min-height: 42px;
}

/* Sub-tabs for segment detail */
.seg-sub-tabs {
    display: flex;
    gap: 0;
}

.seg-sub-tab {
    padding: 0.35rem 0.85rem;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.8rem;
    color: #999;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
}

.seg-sub-tab:hover {
    color: #555;
}

.seg-sub-tab.active {
    color: #475569;
    border-bottom-color: #475569;
}

.seg-sub-content {
    padding: 1rem;
    min-height: 120px;
    max-height: 400px;
    overflow-y: auto;
}

.seg-tab-content {
    display: none;
}

.seg-tab-content.active {
    display: block;
}

.seg-tab-content h4 {
    margin: 0 0 0.5rem;
    font-size: 0.9rem;
    color: #555;
}

.seg-tab-content h4:not(:first-child) {
    margin-top: 1rem;
}

/* Tags */
.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.concept-tag {
    display: inline-block;
    padding: 0.3rem 0.7rem;
    background: #e8eaf6;
    color: #3949ab;
    border-radius: 16px;
    font-size: 0.82rem;
}

.term-tag {
    display: inline-block;
    padding: 0.3rem 0.7rem;
    background: #fff3e0;
    color: #e65100;
    border-radius: 16px;
    font-size: 0.82rem;
}

/* Mindmap */
.mindmap-viewer {
    overflow: auto;
    max-height: 300px;
    border: 1px solid #eee;
    border-radius: 6px;
    background: #fafafa;
}

.mindmap-canvas {
    padding: 1rem;
    transition: transform 0.15s;
}

.mindmap-canvas svg {
    max-width: 100%;
    height: auto;
}

.mindmap-controls {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.5rem;
    justify-content: center;
}

.zoom-btn {
    padding: 0.3rem 0.7rem;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

.zoom-btn:hover {
    background: #f0f0f0;
}

.mindmap-fallback {
    background: #f5f5f5;
    padding: 1rem;
    border-radius: 6px;
    white-space: pre-wrap;
    font-size: 0.85rem;
}

/* Transcript */
.transcript-text {
    white-space: pre-wrap;
    font-size: 0.9rem;
    line-height: 1.7;
    color: #444;
}

/* Empty state */
.empty-state {
    color: #999;
    font-style: italic;
    padding: 1rem 0;
}

/* Chat Suggestions (clickable) */
.chat-suggestion {
    display: block;
    padding: 0.35rem 0.7rem;
    margin: 0.15rem 0;
    background: #e8eaf6;
    color: #3949ab;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 0.9rem;
}

.chat-suggestion:hover {
    background: #c5cae9;
}

/* Desktop: segment panel sits below video on left side */
@media (min-width: 768px) {
    .chat-container {
        align-self: flex-start;
    }
}

/* ===== Video Summary (inside segment card) ===== */

#summary-view .summary-content {
    padding: 1rem;
    max-height: 400px;
    overflow-y: auto;
    line-height: 1.8;
}

.summary-paragraph {
    margin: 0 0 0.75rem;
    font-size: 0.95rem;
    color: #444;
    text-align: justify;
}

.summary-paragraph:last-child {
    margin-bottom: 0;
}

/* ===== Summary Modal (processing.html) ===== */

#summary-modal .modal-body {
    max-height: 500px;
    overflow-y: auto;
    padding: 1rem 1.5rem;
    line-height: 1.7;
}

#summary-modal .summary-paragraph {
    margin: 0 0 0.75rem;
    font-size: 0.95rem;
    color: #444;
    text-align: justify;
}

#summary-modal .modal-nav {
    justify-content: flex-end;
}

#view-summary-btn {
    background: #1e293b;
    color: white;
    border: none;
    padding: 0.5rem 1.25rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
}

#view-summary-btn:hover {
    background: #334155;
}

/* ── Login Page ── */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
}

.login-card {
    background: white;
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    text-align: center;
}

.login-logo {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.login-card h1 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
    color: #333;
}

.login-card p {
    color: #666;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.login-card form {
    text-align: left;
}

.login-card label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #555;
    margin-bottom: 0.3rem;
}

.login-card input {
    width: 100%;
    padding: 0.7rem 0.9rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 0.95rem;
    margin-bottom: 1rem;
    transition: border-color 0.2s;
}

.login-card input:focus {
    outline: none;
    border-color: #475569;
    box-shadow: 0 0 0 3px rgba(71, 85, 105, 0.1);
}

.btn-login {
    width: 100%;
    padding: 0.75rem;
    background: #1e293b;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-login:hover { opacity: 0.9; }
.btn-login:disabled { opacity: 0.6; cursor: not-allowed; }

.login-error {
    display: none;
    margin-top: 1rem;
    padding: 0.6rem;
    background: #fee;
    color: #c33;
    border-radius: 6px;
    font-size: 0.85rem;
    text-align: center;
}

/* ===== FAQ Section ===== */

.faq-content {
    padding: 1rem;
    max-height: 400px;
    overflow-y: auto;
}

/* FAQ — open list (no accordion) */
.faq-item-open {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 0.75rem;
    padding: 0.75rem 1rem;
    background: #fff;
}
.faq-question-row {
    display: flex; align-items: flex-start; gap: 0.4rem; font-size: 0.9rem; font-weight: 500; color: #1a202c;
}
.faq-q-label { color: #667eea; font-weight: 700; flex-shrink: 0; }
.faq-q-text { flex: 1; }
.faq-answer-row {
    display: flex; align-items: flex-start; gap: 0.4rem; margin-top: 0.4rem; font-size: 0.9rem; color: #4a5568; line-height: 1.6;
}
.faq-a-label { color: #48bb78; font-weight: 700; flex-shrink: 0; }
.faq-a-text { flex: 1; }

.faq-actions {
    display: flex; gap: 0.25rem; margin-left: 0.5rem; flex-shrink: 0;
}
.faq-edit-btn, .faq-delete-btn {
    background: none; border: 1px solid #e2e8f0; border-radius: 4px;
    cursor: pointer; padding: 0.15rem 0.35rem; font-size: 0.8rem; transition: background 0.15s;
}
.faq-edit-btn:hover { background: #e8eaf6; }
.faq-delete-btn:hover { background: #fee2e2; }

.faq-form {
    padding: 1rem;
    margin-bottom: 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
}

.faq-form .input-group { margin-bottom: 0.75rem; }

.faq-form textarea, .faq-form input[type="text"] {
    width: 100%;
    padding: 0.5rem 0.7rem;
    border: 1.5px solid #e5e7eb;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    background: #fff;
}

.faq-form textarea:focus, .faq-form input[type="text"]:focus {
    outline: none;
    border-color: #475569;
    box-shadow: 0 0 0 2px rgba(71, 85, 105, 0.12);
}

/* Summary markdown rendering */
.summary-markdown { line-height: 1.7; color: #2d3748; }
.summary-markdown h1, .summary-markdown h2, .summary-markdown h3, .summary-markdown h4 {
    color: #1a202c; margin: 1.2em 0 0.5em; font-weight: 600;
}
.summary-markdown h1 { font-size: 1.5em; border-bottom: 2px solid #667eea; padding-bottom: 0.3em; }
.summary-markdown h2 { font-size: 1.3em; border-bottom: 1px solid #e2e8f0; padding-bottom: 0.2em; }
.summary-markdown h3 { font-size: 1.15em; }
.summary-markdown h4 { font-size: 1.05em; color: #4a5568; }
.summary-markdown p { margin: 0.6em 0; }
.summary-markdown ul, .summary-markdown ol { margin: 0.5em 0; padding-left: 1.5em; }
.summary-markdown li { margin: 0.3em 0; }
.summary-markdown strong { color: #1a202c; }
.summary-markdown code { background: #f7fafc; padding: 0.15em 0.4em; border-radius: 3px; font-size: 0.9em; }
.summary-markdown blockquote { border-left: 3px solid #667eea; margin: 0.8em 0; padding: 0.4em 1em; background: #f7fafc; }
.summary-markdown table { border-collapse: collapse; width: 100%; margin: 0.8em 0; }
.summary-markdown th, .summary-markdown td { border: 1px solid #e2e8f0; padding: 0.5em 0.8em; text-align: left; }
.summary-markdown th { background: #f7fafc; font-weight: 600; }

/* FAQ segment tag — clickable pill that seeks video */
.faq-segment-tag {
    display: inline-block; font-size: 0.75em; padding: 2px 8px; margin-left: 8px;
    background: linear-gradient(135deg, #667eea, #764ba2); color: #fff;
    border-radius: 12px; cursor: pointer; vertical-align: middle; white-space: nowrap;
    transition: opacity 0.2s;
}
.faq-segment-tag:hover { opacity: 0.85; }

/* FAQ autocomplete in chat */
.faq-autocomplete {
    display: none; position: absolute; bottom: 100%; left: 0; right: 0;
    background: #fff; border: 1px solid #e2e8f0; border-radius: 8px;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.1); max-height: 200px; overflow-y: auto; z-index: 50;
}
.faq-ac-item {
    padding: 8px 12px; cursor: pointer; font-size: 0.85rem; color: #333;
    border-bottom: 1px solid #f1f5f9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.faq-ac-item:last-child { border-bottom: none; }
.faq-ac-item:hover, .faq-ac-item.active { background: #f0f4ff; color: #667eea; }
.chat-input-container { position: relative; }