/* CSS Variables */
:root {
    /* Dark theme (default) */
    --bg-primary: #0a0a0a;
    --bg-secondary: #111111;
    --bg-tertiary: #1a1a1a;
    --bg-hover: #222222;
    --bg-active: #2a2a2a;
    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted: #52525b;
    --border-color: #27272a;
    --accent: #8b5cf6;
    --accent-hover: #a78bfa;
    --accent-light: rgba(139, 92, 246, 0.15);
    --accent-glow: rgba(139, 92, 246, 0.4);
    --success: #22c55e;
    --error: #ef4444;
    --warning: #f59e0b;
    --user-bubble: linear-gradient(135deg, #8b5cf6, #6366f1);
    --assistant-bubble: #18181b;
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.6);
    --gradient-1: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-2: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-3: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

[data-theme="light"] {
    --bg-primary: #fafafa;
    --bg-secondary: #f4f4f5;
    --bg-tertiary: #e4e4e7;
    --bg-hover: #d4d4d8;
    --bg-active: #a1a1aa;
    --text-primary: #18181b;
    --text-secondary: #52525b;
    --text-muted: #a1a1aa;
    --border-color: #d4d4d8;
    --accent: #7c3aed;
    --accent-hover: #6d28d9;
    --accent-light: rgba(124, 58, 237, 0.1);
    --accent-glow: rgba(124, 58, 237, 0.3);
    --user-bubble: linear-gradient(135deg, #7c3aed, #6366f1);
    --assistant-bubble: #ffffff;
    --glass-bg: rgba(255, 255, 255, 0.8);
    --glass-border: rgba(0, 0, 0, 0.08);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.15);
}

/* Reset & Base */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
}

/* App Container */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
    width: 280px;
    min-width: 280px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: var(--gradient-1);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {

    0%,
    100% {
        box-shadow: 0 0 0 0 var(--accent-glow);
    }

    50% {
        box-shadow: 0 0 20px 5px var(--accent-glow);
    }
}

.logo-icon svg {
    color: white;
    width: 20px;
    height: 20px;
}

.new-chat-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.new-chat-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    transform: scale(1.08) rotate(90deg);
    box-shadow: 0 0 20px var(--accent-glow);
}

/* Model Selector */
.model-selector {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.model-selector label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.model-selector select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.model-selector select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.model-selector select:hover {
    background-color: var(--bg-hover);
}

/* Search Box */
.search-box {
    padding: 12px 16px;
    position: relative;
}

.search-box svg {
    position: absolute;
    left: 28px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    transition: color 0.3s ease;
}

.search-box input {
    width: 100%;
    padding: 10px 12px 10px 40px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.search-box input:focus+svg,
.search-box:focus-within svg {
    color: var(--accent);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

/* Conversations List */
.conversations-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

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

.conversation-group-title {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    padding: 8px 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.conversation-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 2px;
    position: relative;
    overflow: hidden;
}

.conversation-item::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--accent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.conversation-item:hover {
    background: var(--bg-hover);
    transform: translateX(4px);
}

.conversation-item.active {
    background: var(--accent-light);
}

.conversation-item.active::before {
    opacity: 0.1;
}

.conversation-item svg {
    flex-shrink: 0;
    color: var(--text-muted);
    transition: color 0.3s ease;
}

.conversation-item.active svg,
.conversation-item:hover svg {
    color: var(--accent);
}

.conversation-title {
    flex: 1;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-actions {
    opacity: 0;
    display: flex;
    gap: 4px;
    transition: opacity 0.3s ease;
}

.conversation-item:hover .conversation-actions {
    opacity: 1;
}

.conversation-action-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.conversation-action-btn:hover {
    background: var(--bg-active);
    color: var(--text-primary);
    transform: scale(1.1);
}

.conversation-action-btn.delete:hover {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.theme-toggle {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-toggle:hover {
    background: var(--bg-hover);
    transform: scale(1.02);
}

.sun-icon {
    display: none;
}

.moon-icon {
    display: block;
}

[data-theme="light"] .sun-icon {
    display: block;
}

[data-theme="light"] .moon-icon {
    display: none;
}

/* Sidebar Toggle (Mobile) */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 1000;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 12px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease;
}

.sidebar-toggle:hover {
    transform: scale(1.05);
}

/* ==================== MAIN CHAT AREA ==================== */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
    background: var(--bg-primary);
}

/* Welcome Screen */
.welcome-screen {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: fadeInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.welcome-screen.hidden {
    display: none;
}

.welcome-content {
    text-align: center;
    max-width: 700px;
}

.welcome-logo {
    width: 100px;
    height: 100px;
    margin: 0 auto 24px;
    position: relative;
}

.welcome-logo-inner {
    width: 100%;
    height: 100%;
    background: var(--gradient-1);
    border-radius: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: float 4s ease-in-out infinite, glow 3s ease-in-out infinite;
    box-shadow: 0 10px 40px var(--accent-glow);
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

@keyframes glow {

    0%,
    100% {
        box-shadow: 0 10px 40px var(--accent-glow);
    }

    50% {
        box-shadow: 0 15px 60px var(--accent-glow), 0 0 80px var(--accent-light);
    }
}

.welcome-logo-inner svg {
    color: white;
}

.welcome-content h1 {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 12px;
    background: linear-gradient(135deg, var(--text-primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmer 3s linear infinite;
    background-size: 200% 100%;
}

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

    100% {
        background-position: 200% 0;
    }
}

.welcome-content p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 24px;
}

.model-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 32px;
    animation: slideIn 0.5s ease 0.3s both;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.model-icon {
    font-size: 1rem;
}

.feature-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.feature-card {
    padding: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
    animation: cardFadeIn 0.5s ease both;
}

.feature-card:nth-child(1) {
    animation-delay: 0.1s;
}

.feature-card:nth-child(2) {
    animation-delay: 0.15s;
}

.feature-card:nth-child(3) {
    animation-delay: 0.2s;
}

.feature-card:nth-child(4) {
    animation-delay: 0.25s;
}

.feature-card:nth-child(5) {
    animation-delay: 0.3s;
}

.feature-card:nth-child(6) {
    animation-delay: 0.35s;
}

@keyframes cardFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.feature-card:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3), 0 0 0 1px var(--accent);
}

.feature-icon {
    font-size: 1.8rem;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border-radius: 12px;
    flex-shrink: 0;
}

.feature-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.feature-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.feature-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ==================== MESSAGES ==================== */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: none;
    scroll-behavior: smooth;
}

.messages-container.active {
    display: block;
}

.message {
    max-width: 850px;
    margin: 0 auto 24px;
    display: flex;
    gap: 16px;
    animation: messageSlideIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) both;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.message-avatar {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.message:hover .message-avatar {
    transform: scale(1.08);
}

.message.user .message-avatar {
    background: var(--user-bubble);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.message.assistant .message-avatar {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
}

.message-avatar svg {
    width: 18px;
    height: 18px;
    color: white;
}

.message.assistant .message-avatar svg {
    color: var(--accent);
}

.message-content {
    flex: 1;
    min-width: 0;
}

.message-role {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.message-text {
    color: var(--text-primary);
    line-height: 1.75;
}

/* Streaming Text Animation */
.streaming-text {
    display: inline;
}

.streaming-cursor {
    display: inline-block;
    width: 2px;
    height: 1.2em;
    background: var(--accent);
    margin-left: 2px;
    animation: blink 0.8s ease-in-out infinite;
    vertical-align: text-bottom;
}

@keyframes blink {

    0%,
    50% {
        opacity: 1;
    }

    51%,
    100% {
        opacity: 0;
    }
}

/* Character-by-character animation */
.char-animate {
    display: inline-block;
    opacity: 0;
    animation: charFadeIn 0.1s ease forwards;
}

@keyframes charFadeIn {
    to {
        opacity: 1;
    }
}

/* ==================== SEARCHING INDICATOR ==================== */
.searching-indicator {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 30px;
    padding: 12px 24px;
    display: none;
    align-items: center;
    gap: 12px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.searching-indicator.visible {
    display: flex;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.search-animation {
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-globe {
    animation: globeSpin 2s linear infinite;
}

.search-globe svg {
    color: var(--accent);
}

@keyframes globeSpin {
    from {
        transform: rotateY(0deg);
    }

    to {
        transform: rotateY(360deg);
    }
}

.search-dots {
    display: flex;
    gap: 4px;
}

.search-dots span {
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
    animation: searchBounce 1.4s ease-in-out infinite;
}

.search-dots span:nth-child(1) {
    animation-delay: 0s;
}

.search-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.search-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes searchBounce {

    0%,
    80%,
    100% {
        transform: scale(0.6);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ==================== INPUT AREA ==================== */
.input-area {
    padding: 16px 24px 24px;
    background: linear-gradient(to top, var(--bg-primary), transparent);
}

.input-wrapper {
    max-width: 850px;
    margin: 0 auto;
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-light), 0 8px 30px rgba(0, 0, 0, 0.2);
    transform: translateY(-2px);
}

.input-wrapper textarea {
    width: 100%;
    padding: 18px 60px 18px 22px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    resize: none;
    line-height: 1.5;
    max-height: 200px;
}

.input-wrapper textarea:focus {
    outline: none;
}

.input-wrapper textarea::placeholder {
    color: var(--text-muted);
}

.send-btn {
    position: absolute;
    right: 10px;
    bottom: 10px;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 12px;
    background: var(--accent);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px var(--accent-glow);
}

.send-btn:hover {
    background: var(--accent-hover);
    transform: scale(1.1);
    box-shadow: 0 6px 20px var(--accent-glow);
}

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

.send-btn:disabled {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.input-hint {
    max-width: 850px;
    margin: 12px auto 0;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.input-hint kbd {
    padding: 3px 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.7rem;
    box-shadow: 0 2px 0 var(--border-color);
}

/* ==================== LEARNING COMPONENTS ==================== */

/* Flashcards */
.flashcards-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin: 16px 0;
}

.flashcard {
    height: 180px;
    perspective: 1000px;
    cursor: pointer;
}

.flashcard-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.flashcard.flipped .flashcard-inner {
    transform: rotateY(180deg);
}

.flashcard-front,
.flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    font-size: 1rem;
    line-height: 1.5;
}

.flashcard-front {
    background: linear-gradient(135deg, var(--accent), #6366f1);
    color: white;
    box-shadow: 0 8px 24px var(--accent-glow);
}

.flashcard-back {
    background: var(--bg-secondary);
    border: 2px solid var(--accent);
    transform: rotateY(180deg);
}

.flashcard-hint {
    position: absolute;
    bottom: 12px;
    font-size: 0.75rem;
    opacity: 0.7;
}

/* Quiz */
.quiz-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    margin: 16px 0;
    animation: slideUp 0.5s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.quiz-question {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.quiz-option {
    padding: 14px 18px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 12px;
}

.quiz-option:hover:not(.disabled) {
    border-color: var(--accent);
    background: var(--accent-light);
    transform: translateX(8px);
}

.quiz-option.selected {
    border-color: var(--accent);
    background: var(--accent-light);
}

.quiz-option.correct {
    border-color: var(--success);
    background: rgba(34, 197, 94, 0.15);
}

.quiz-option.incorrect {
    border-color: var(--error);
    background: rgba(239, 68, 68, 0.15);
}

.quiz-option.disabled {
    cursor: default;
    opacity: 0.7;
}

.quiz-option-letter {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
}

.quiz-explanation {
    margin-top: 20px;
    padding: 16px;
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid var(--success);
    border-radius: 12px;
    animation: fadeIn 0.4s ease;
    display: none;
}

.quiz-explanation.show {
    display: block;
}

/* Step-by-step Quiz Enhancements */
.quiz-container.step-by-step .quiz-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.quiz-progress-text {
    margin-left: auto;
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 600;
}

.quiz-progress-bar {
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 20px;
}

.quiz-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #6366f1);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.quiz-questions-wrapper {
    min-height: 200px;
}

.quiz-question-slide {
    animation: fadeIn 0.3s ease;
}

.quiz-navigation {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.quiz-nav-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}

.quiz-nav-btn:hover:not(:disabled) {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.quiz-nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.quiz-nav-btn.next {
    margin-left: auto;
}

.quiz-final-result {
    display: none;
}

.quiz-final-result.show {
    display: block;
    margin-top: 20px;
}

.quiz-score-card {
    text-align: center;
    padding: 24px;
    background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-secondary));
    border: 1px solid var(--border-color);
    border-radius: 16px;
}

.score-emoji {
    font-size: 3rem;
    margin-bottom: 12px;
}

.score-text {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.score-message {
    color: var(--text-secondary);
    font-size: 1rem;
}

.quiz-result {
    margin-top: 12px;
    display: none;
}

.quiz-result.show {
    display: block;
}

.result-correct {
    color: var(--success);
    font-weight: 600;
}

.result-incorrect {
    color: var(--error);
    font-weight: 600;
}

/* Timeline */
.timeline-container {
    margin: 16px 0;
    position: relative;
    padding-left: 30px;
}

.timeline-container::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(to bottom, var(--accent), transparent);
}

.timeline-item {
    position: relative;
    margin-bottom: 24px;
    padding: 16px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    animation: timelineSlide 0.5s ease both;
}

.timeline-item:nth-child(1) {
    animation-delay: 0.1s;
}

.timeline-item:nth-child(2) {
    animation-delay: 0.2s;
}

.timeline-item:nth-child(3) {
    animation-delay: 0.3s;
}

.timeline-item:nth-child(4) {
    animation-delay: 0.4s;
}

@keyframes timelineSlide {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -26px;
    top: 20px;
    width: 12px;
    height: 12px;
    background: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 0 4px var(--bg-primary), 0 0 20px var(--accent-glow);
}

.timeline-date {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.timeline-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.timeline-description {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Comparison */
.comparison-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin: 16px 0;
}

.comparison-side {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    animation: comparisonSlide 0.5s ease both;
}

.comparison-side:first-child {
    animation-delay: 0.1s;
}

.comparison-side:last-child {
    animation-delay: 0.2s;
}

@keyframes comparisonSlide {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.comparison-header {
    padding: 16px 20px;
    background: var(--gradient-1);
    color: white;
    font-weight: 600;
    font-size: 1.1rem;
    text-align: center;
}

.comparison-side:last-child .comparison-header {
    background: var(--gradient-2);
}

.comparison-items {
    padding: 16px;
}

.comparison-item {
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 0.9rem;
    transition: transform 0.2s ease;
}

.comparison-item:hover {
    transform: translateX(4px);
}

/* Code Playground */
.playground-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    margin: 16px 0;
}

.playground-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.playground-lang {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.playground-run-btn {
    padding: 8px 16px;
    background: var(--success);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
}

.playground-run-btn:hover {
    background: #16a34a;
    transform: scale(1.05);
}

.playground-editor {
    padding: 16px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    min-height: 120px;
    background: #0d1117;
    color: #c9d1d9;
    resize: vertical;
}

.playground-output {
    padding: 16px;
    background: #161b22;
    border-top: 1px solid var(--border-color);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    color: var(--success);
    min-height: 60px;
    white-space: pre-wrap;
}

.playground-output.error {
    color: var(--error);
}

/* Chart Container */
.chart-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    margin: 16px 0;
}

.chart-title {
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

/* Mind Map */
.mindmap-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    margin: 16px 0;
    overflow-x: auto;
}

.mindmap-center {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 20px;
}

.mindmap-node {
    padding: 12px 24px;
    background: var(--gradient-1);
    color: white;
    border-radius: 30px;
    font-weight: 600;
    box-shadow: 0 4px 20px var(--accent-glow);
}

.mindmap-branches {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    justify-content: center;
}

.mindmap-branch {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.mindmap-branch-title {
    padding: 10px 20px;
    background: var(--bg-tertiary);
    border: 2px solid var(--accent);
    border-radius: 20px;
    font-weight: 500;
}

.mindmap-children {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mindmap-child {
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    font-size: 0.875rem;
    text-align: center;
}

/* ==================== CONTEXT MENU ==================== */
.context-menu {
    position: fixed;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 6px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    display: none;
    min-width: 180px;
    animation: contextMenuIn 0.2s ease;
}

@keyframes contextMenuIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.context-menu.visible {
    display: block;
}

.context-menu-item {
    width: 100%;
    padding: 12px 14px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.875rem;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.context-menu-item:hover {
    background: var(--bg-hover);
    transform: translateX(4px);
}

.context-menu-item.delete:hover {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

/* ==================== LOADING ==================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.loading-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    color: var(--text-primary);
    font-weight: 500;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 6px;
    padding: 12px;
    align-items: center;
}

.typing-indicator span {
    width: 10px;
    height: 10px;
    background: var(--accent);
    border-radius: 50%;
    animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(1) {
    animation-delay: 0s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {

    0%,
    60%,
    100% {
        transform: translateY(0) scale(1);
    }

    30% {
        transform: translateY(-12px) scale(1.1);
    }
}

/* ==================== MARKDOWN STYLES ==================== */
.message-text h1,
.message-text h2,
.message-text h3 {
    margin: 1.2em 0 0.6em;
    font-weight: 700;
}

.message-text h1 {
    font-size: 1.5em;
}

.message-text h2 {
    font-size: 1.3em;
}

.message-text h3 {
    font-size: 1.1em;
}

.message-text p {
    margin-bottom: 0.8em;
}

.message-text ul,
.message-text ol {
    margin: 0.8em 0;
    padding-left: 1.5em;
}

.message-text li {
    margin-bottom: 0.3em;
}

.message-text a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s ease;
}

.message-text a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.message-text blockquote {
    border-left: 4px solid var(--accent);
    padding-left: 1em;
    margin: 1em 0;
    color: var(--text-secondary);
    font-style: italic;
}

.message-text table {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
    border-radius: 12px;
    overflow: hidden;
}

.message-text th,
.message-text td {
    border: 1px solid var(--border-color);
    padding: 12px 16px;
    text-align: left;
}

.message-text th {
    background: var(--bg-tertiary);
    font-weight: 600;
}

.message-text tr:hover td {
    background: var(--bg-hover);
}

.message-text hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 2em 0;
}

/* Code Blocks */
.message-text code {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.9em;
}

.message-text :not(pre)>code {
    background: var(--bg-tertiary);
    padding: 3px 8px;
    border-radius: 6px;
    color: var(--accent);
}

.message-text pre {
    background: #0d1117;
    border-radius: 12px;
    margin: 1em 0;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.code-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: #161b22;
    border-bottom: 1px solid #30363d;
    font-size: 0.8rem;
    color: #8b949e;
    flex-wrap: wrap;
    gap: 8px;
}

.code-lang-badge {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 500;
    padding: 2px 8px;
    background: rgba(88, 166, 255, 0.15);
    color: #58a6ff;
    border-radius: 4px;
    font-size: 0.75rem;
}

.code-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.run-in-notebook-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    background: linear-gradient(135deg, #238636, #2ea043);
    color: white;
    cursor: pointer;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
    font-weight: 500;
}

.run-in-notebook-btn:hover {
    background: linear-gradient(135deg, #2ea043, #3fb950);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(46, 160, 67, 0.4);
}

.copy-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    background: #21262d;
    color: #8b949e;
    cursor: pointer;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
}

.copy-btn:hover {
    background: #30363d;
    color: #c9d1d9;
    transform: scale(1.05);
}

.copy-btn.copied {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
}

.message-text pre code {
    display: block;
    padding: 16px;
    overflow-x: auto;
    color: #c9d1d9;
    font-size: 0.9rem;
    line-height: 1.6;
}

/* Mermaid */
.mermaid {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
    margin: 1em 0;
    text-align: center;
}

/* YouTube */
.youtube-thumbnail {
    display: block;
    margin: 1em 0;
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.youtube-thumbnail:hover {
    transform: scale(1.02);
}

.youtube-thumbnail img {
    width: 100%;
    display: block;
}

.youtube-thumbnail .play-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 72px;
    height: 50px;
    background: rgba(255, 0, 0, 0.9);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, background 0.3s ease;
}

.youtube-thumbnail:hover .play-button {
    background: #ff0000;
    transform: translate(-50%, -50%) scale(1.1);
}

/* Images */
.message-text img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    margin: 1em 0;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

/* LaTeX */
.katex {
    font-size: 1.1em;
}

.katex-display {
    margin: 1.2em 0;
    overflow-x: auto;
    padding: 12px 0;
}

/* ==================== SCROLLBAR ==================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ==================== MOBILE RESPONSIVE ==================== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 999;
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .feature-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .welcome-content h1 {
        font-size: 1.6rem;
    }

    .input-area {
        padding: 12px 16px 16px;
    }

    .messages-container {
        padding: 16px;
    }

    .message {
        gap: 12px;
    }

    .message-avatar {
        width: 34px;
        height: 34px;
    }

    .comparison-container {
        grid-template-columns: 1fr;
    }
}

/* ==================== PRINT ==================== */
@media print {

    .sidebar,
    .input-area,
    .sidebar-toggle,
    .searching-indicator {
        display: none !important;
    }

    .chat-main {
        padding: 0;
    }

    .messages-container {
        overflow: visible;
        display: block !important;
    }

    .message {
        break-inside: avoid;
    }
}

/* ==================== FILE UPLOAD ==================== */
.file-preview-area {
    display: none;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 24px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    max-height: 200px;
    overflow-y: auto;
}

.file-preview-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    min-width: 180px;
    max-width: 280px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.file-preview-item.pdf .preview-thumbnail {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.file-preview-item.image .preview-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

.preview-thumbnail {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-hover);
    flex-shrink: 0;
    overflow: hidden;
}

.preview-thumbnail svg {
    color: white;
}

.preview-info {
    flex: 1;
    min-width: 0;
}

.preview-name {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

.preview-size {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.preview-remove {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.preview-remove:hover {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
    transform: scale(1.1);
}

/* Drop Zone Overlay */
.drop-zone-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.drop-zone-overlay.visible {
    display: flex;
    opacity: 1;
}

.drop-zone-content {
    text-align: center;
    color: white;
    animation: pulse 1.5s ease-in-out infinite;
}

.drop-zone-content svg {
    color: var(--accent);
    margin-bottom: 16px;
}

.drop-zone-content span {
    display: block;
    font-size: 1.5rem;
    font-weight: 600;
}

.drop-zone-content .drop-hint {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 8px;
}

/* Input Actions */
.input-actions {
    display: flex;
    gap: 4px;
    margin-right: 8px;
}

.attachment-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.attachment-btn:hover {
    background: var(--bg-hover);
    color: var(--accent);
    transform: scale(1.1);
}

/* Analytics Button */
.analytics-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 12px;
    transition: all 0.3s ease;
}

.analytics-btn:hover {
    background: var(--bg-hover);
    color: var(--accent);
    border-color: var(--accent);
}

.analytics-btn svg {
    color: var(--accent);
}

/* Context Badge */
.context-badge {
    background: var(--accent-light);
    color: var(--accent);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
}

/* ==================== ENHANCED FLASHCARDS ==================== */
.flashcards-wrapper {
    margin: 16px 0;
}

.flashcards-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.flashcards-count {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.flashcards-controls {
    display: flex;
    gap: 8px;
}

.flashcard-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.flashcard-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.flashcard-number {
    position: absolute;
    top: 12px;
    right: 12px;
    font-size: 0.75rem;
    opacity: 0.7;
}

.flashcard-content {
    font-size: 1.1rem;
    line-height: 1.6;
}

.flashcard-mark {
    position: absolute;
    bottom: 12px;
    padding: 8px 16px;
    background: var(--success);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.flashcard-mark:hover {
    transform: scale(1.05);
}

.flashcard.learned {
    opacity: 0.5;
    pointer-events: none;
}

/* ==================== MESSAGE ATTACHMENTS ==================== */
.message-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 8px 0;
}

.attachment-thumb {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.attachment-thumb:hover {
    transform: scale(1.02);
}

.attachment-thumb.image {
    width: 120px;
    height: 90px;
    background: var(--bg-tertiary);
}

.attachment-thumb.image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.attachment-thumb.pdf {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    font-size: 0.8rem;
    font-weight: 500;
}

.attachment-thumb.pdf svg {
    flex-shrink: 0;
}

.attachment-thumb.pdf span {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ==================== ATTACHMENT MODAL ==================== */
.attachment-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.attachment-modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
}

.attachment-modal-content img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.attachment-modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: var(--bg-secondary);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

.attachment-modal-close:hover {
    transform: scale(1.1);
}

/* ==================== ENHANCED QUIZ ==================== */
.quiz-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.quiz-icon {
    font-size: 1.5rem;
}

.quiz-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    font-weight: 600;
}

.quiz-option-indicator {
    margin-left: auto;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quiz-option.correct .quiz-option-indicator::after {
    content: '✓';
    color: var(--success);
    font-weight: bold;
}

.quiz-option.incorrect .quiz-option-indicator::after {
    content: '✗';
    color: var(--error);
    font-weight: bold;
}

.quiz-result {
    display: none;
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: 10px;
    font-weight: 600;
    text-align: center;
}

.quiz-result.show {
    display: block;
    animation: slideUp 0.3s ease;
}

.quiz-result.correct {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.quiz-result.incorrect {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

.quiz-explanation {
    display: none;
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: 10px;
    border-left: 4px solid var(--accent);
}

.quiz-explanation.show {
    display: block;
    animation: slideUp 0.3s ease;
}

/* ==================== ENHANCED TIMELINE ==================== */
.timeline-container {
    position: relative;
    padding-left: 32px;
    margin: 16px 0;
}

.timeline-container::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(to bottom, var(--accent), var(--accent-light));
    border-radius: 2px;
}

.timeline-item {
    position: relative;
    padding-bottom: 24px;
    animation: slideIn 0.5s ease both;
}

.timeline-marker {
    position: absolute;
    left: -28px;
    top: 4px;
    width: 14px;
    height: 14px;
    background: var(--accent);
    border-radius: 50%;
    border: 3px solid var(--bg-primary);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.timeline-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
}

.timeline-date {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 4px;
}

.timeline-title {
    font-weight: 600;
    margin-bottom: 8px;
}

.timeline-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* ==================== ENHANCED COMPARISON ==================== */
.comparison-header-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 16px;
    align-items: center;
    margin-bottom: 16px;
}

.comparison-header {
    text-align: center;
    font-weight: 600;
    font-size: 1.1rem;
    padding: 12px;
    border-radius: 10px;
}

.comparison-header.left {
    background: linear-gradient(135deg, var(--accent), #6366f1);
    color: white;
}

.comparison-header.right {
    background: linear-gradient(135deg, #06b6d4, #22d3ee);
    color: white;
}

.comparison-vs {
    font-weight: 700;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.comparison-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.comparison-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.comparison-cell {
    padding: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.9rem;
}

/* ==================== ACCORDION ==================== */
.accordion-container {
    margin: 16px 0;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
}

.accordion-item {
    border-bottom: 1px solid var(--border-color);
}

.accordion-item:last-child {
    border-bottom: none;
}

.accordion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: var(--bg-secondary);
    cursor: pointer;
    transition: background 0.3s ease;
    font-weight: 500;
}

.accordion-header:hover {
    background: var(--bg-hover);
}

.accordion-icon {
    transition: transform 0.3s ease;
}

.accordion-item.open .accordion-icon {
    transform: rotate(180deg);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.accordion-item.open .accordion-content {
    max-height: 500px;
}

.accordion-body {
    padding: 16px;
    background: var(--bg-tertiary);
}

/* ==================== TABS ==================== */
.tabs-container {
    margin: 16px 0;
}

.tabs-header {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 16px;
}

.tab-btn {
    padding: 12px 20px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.tab-btn::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--accent);
}

.tab-btn.active::after {
    transform: scaleX(1);
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* ==================== STEPPER ==================== */
.stepper-container {
    margin: 16px 0;
}

.stepper-progress {
    display: flex;
    justify-content: space-between;
    margin-bottom: 24px;
    position: relative;
}

.stepper-progress::before {
    content: '';
    position: absolute;
    top: 16px;
    left: 24px;
    right: 24px;
    height: 3px;
    background: var(--border-color);
}

.stepper-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    position: relative;
    z-index: 1;
}

.stepper-number {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: 3px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    transition: all 0.3s ease;
}

.stepper-step.active .stepper-number,
.stepper-step.completed .stepper-number {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.stepper-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    transition: color 0.3s ease;
}

.stepper-step.active .stepper-label {
    color: var(--accent);
    font-weight: 500;
}

.stepper-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    min-height: 100px;
    margin-bottom: 16px;
}

.stepper-panel {
    display: none;
}

.stepper-panel.active {
    display: block;
}

.stepper-nav {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.stepper-btn {
    padding: 10px 20px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.stepper-btn:hover:not(:disabled) {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.stepper-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ==================== CALLOUT ==================== */
.callout-container {
    display: flex;
    gap: 16px;
    padding: 16px;
    border-radius: 12px;
    margin: 16px 0;
}

.callout-container.info {
    background: rgba(59, 130, 246, 0.1);
    border-left: 4px solid #3b82f6;
}

.callout-container.warning {
    background: rgba(245, 158, 11, 0.1);
    border-left: 4px solid #f59e0b;
}

.callout-container.success {
    background: rgba(34, 197, 94, 0.1);
    border-left: 4px solid #22c55e;
}

.callout-container.error {
    background: rgba(239, 68, 68, 0.1);
    border-left: 4px solid #ef4444;
}

.callout-container.tip {
    background: rgba(168, 85, 247, 0.1);
    border-left: 4px solid #a855f7;
}

.callout-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.callout-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.callout-text {
    color: var(--text-secondary);
}

/* ==================== DEFINITION ==================== */
.definition-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin: 16px 0;
}

.definition-term {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 8px;
}

.definition-meaning {
    line-height: 1.7;
    margin-bottom: 12px;
}

.definition-example {
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    font-style: italic;
    color: var(--text-secondary);
}

/* ==================== CHECKLIST ==================== */
.checklist-container {
    margin: 16px 0;
}

.checklist-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    margin-bottom: 8px;
    transition: all 0.3s ease;
}

.checklist-item:hover {
    background: var(--bg-hover);
}

.checklist-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--accent);
    cursor: pointer;
}

.checklist-item label {
    flex: 1;
    cursor: pointer;
    transition: all 0.3s ease;
}

.checklist-item.checked label {
    text-decoration: line-through;
    color: var(--text-muted);
}

/* ==================== MIND MAP ENHANCED ==================== */
.mindmap-container {
    padding: 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    margin: 16px 0;
    overflow-x: auto;
}

.mindmap-center-node {
    text-align: center;
    margin-bottom: 24px;
}

.mindmap-center-text {
    display: inline-block;
    padding: 16px 32px;
    background: linear-gradient(135deg, var(--accent), #6366f1);
    color: white;
    font-weight: 700;
    font-size: 1.2rem;
    border-radius: 30px;
    box-shadow: 0 8px 24px var(--accent-glow);
}

.mindmap-branches {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: center;
}

.mindmap-branch {
    flex: 1;
    min-width: 200px;
    max-width: 280px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    padding: 16px;
    border-top: 4px solid var(--branch-color, var(--accent));
}

.mindmap-branch-head {
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--branch-color, var(--accent));
}

.mindmap-branch-children {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mindmap-leaf {
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: 8px;
    font-size: 0.9rem;
}

/* ==================== CHART WRAPPER ==================== */
.chart-wrapper {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin: 16px 0;
}

.chart-title {
    font-weight: 600;
    margin-bottom: 16px;
    text-align: center;
}

.chart-canvas-wrapper {
    height: 250px;
}

/* ==================== PLAYGROUND ENHANCED ==================== */
.playground-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    margin: 16px 0;
}

.playground-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.playground-lang {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    font-size: 0.85rem;
}

.playground-dot {
    width: 10px;
    height: 10px;
    background: var(--success);
    border-radius: 50%;
}

.playground-actions {
    display: flex;
    gap: 8px;
}

.playground-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.playground-btn.run {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.playground-btn.run:hover {
    opacity: 0.9;
    transform: scale(1.02);
}

.playground-btn.copy:hover {
    background: var(--bg-hover);
}

.playground-editor-wrapper {
    padding: 0;
}

.playground-editor {
    width: 100%;
    min-height: 120px;
    padding: 16px;
    background: #0d1117;
    border: none;
    color: #e6edf3;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    resize: vertical;
}

.playground-editor:focus {
    outline: none;
}

.playground-output-wrapper {
    border-top: 1px solid var(--border-color);
}

.playground-output-header {
    padding: 8px 16px;
    background: var(--bg-tertiary);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
}

.playground-output {
    padding: 16px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    white-space: pre-wrap;
    min-height: 60px;
    max-height: 200px;
    overflow-y: auto;
    color: var(--text-secondary);
}

.playground-output.error {
    color: var(--error);
}

.playground-output.success {
    color: var(--success);
}

/* ==================== GENERATED IMAGES ==================== */
.generated-image-container {
    margin: 16px 0;
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    max-width: 512px;
}

.generated-image {
    width: 100%;
    display: block;
    cursor: pointer;
    transition: transform 0.3s ease, filter 0.3s ease;
}

.generated-image:hover {
    transform: scale(1.02);
    filter: brightness(1.1);
}

.image-actions {
    padding: 12px;
    display: flex;
    gap: 8px;
    background: var(--bg-secondary);
}

.image-download-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
}

.image-download-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

/* Image generating placeholder animation */
.image-generating {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px;
    background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-secondary));
    border-radius: 12px;
    border: 1px dashed var(--border-color);
    margin: 16px 0;
    animation: shimmer 2s infinite;
}

.image-generating-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    animation: pulse 1.5s infinite;
}

.image-generating-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Image generating placeholder in message */
.image-generating-placeholder {
    padding: 32px;
    background: linear-gradient(135deg, var(--bg-tertiary) 0%, var(--bg-secondary) 50%, var(--bg-tertiary) 100%);
    background-size: 200% 100%;
    animation: shimmerGradient 2s ease infinite;
    border-radius: 12px;
    border: 1px dashed var(--border-color);
    margin-top: 12px;
}

.image-gen-animation {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.image-gen-icon {
    font-size: 2.5rem;
    animation: bounce 1s ease infinite;
}

.image-gen-text {
    color: var(--text-secondary);
    font-weight: 500;
}

.image-gen-dots {
    display: flex;
    gap: 6px;
}

.image-gen-dots span {
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    animation: dotPulse 1.4s infinite;
}

.image-gen-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.image-gen-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes shimmerGradient {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

@keyframes dotPulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.5;
    }

    50% {
        transform: scale(1.2);
        opacity: 1;
    }
}

@keyframes shimmer {

    0%,
    100% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

/* ==================== CITATIONS BLOCK ==================== */
.citations-container {
    margin: 16px 0;
    padding: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

.citations-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-size: 0.9rem;
}

.citations-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.citation-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.2s;
    border: 1px solid transparent;
}

.citation-item:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    transform: translateX(4px);
}

.citation-index {
    font-weight: 700;
    color: var(--accent);
    font-size: 0.85rem;
    min-width: 28px;
}

.citation-title {
    flex: 1;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.citation-domain {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-primary);
    padding: 2px 8px;
    border-radius: 4px;
}

.citation-item svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

/* ==================== FULLSCREEN IMAGE MODAL ==================== */
.fullscreen-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

.fullscreen-modal.show {
    opacity: 1;
    visibility: visible;
}

.fullscreen-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(8px);
}

.fullscreen-content {
    position: relative;
    max-width: 95vw;
    max-height: 95vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: scaleIn 0.3s ease;
}

@keyframes scaleIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.fullscreen-close {
    position: absolute;
    top: -50px;
    right: 0;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.fullscreen-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.fullscreen-image {
    max-width: 100%;
    max-height: calc(95vh - 100px);
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.fullscreen-caption {
    margin-top: 16px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
    text-align: center;
}

.fullscreen-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.fullscreen-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.fullscreen-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
}

/* ==================== JUPYTER NOTEBOOK PANEL (70-30 Split) ==================== */
.notebook-panel {
    position: fixed;
    top: 0;
    right: -35vw;
    width: 35vw;
    min-width: 400px;
    max-width: 600px;
    height: 100vh;
    background: var(--bg-primary);
    border-left: 1px solid var(--border-color);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.3);
}

.notebook-panel.open {
    right: 0;
}

/* 70-30 Split: Chat area shrinks when notebook opens */
.chat-main.notebook-active {
    margin-right: 35vw;
    transition: margin-right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (max-width: 1200px) {
    .notebook-panel {
        width: 45vw;
        right: -45vw;
    }

    .chat-main.notebook-active {
        margin-right: 45vw;
    }
}

@media (max-width: 768px) {
    .notebook-panel {
        width: 100vw;
        right: -100vw;
        min-width: unset;
    }

    .chat-main.notebook-active {
        margin-right: 0;
        opacity: 0.3;
        pointer-events: none;
    }
}

.notebook-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.notebook-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 1rem;
}

.notebook-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.notebook-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.notebook-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.notebook-btn.primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.notebook-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 6px;
}

.notebook-close:hover {
    background: var(--error);
    color: white;
}

.notebook-cells {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.notebook-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
}

.notebook-empty svg {
    margin-bottom: 16px;
    opacity: 0.5;
}

.notebook-empty p {
    margin-bottom: 16px;
}

.notebook-cell {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    margin-bottom: 12px;
    overflow: hidden;
}

.notebook-cell.running {
    border-color: var(--accent);
}

.cell-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.cell-number {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.cell-actions {
    display: flex;
    gap: 4px;
}

.cell-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 4px;
}

.cell-btn:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.cell-btn.run:hover {
    color: var(--success);
}

.cell-btn.delete:hover {
    color: var(--error);
}

.cell-code {
    width: 100%;
    min-height: 80px;
    padding: 12px;
    background: #0d1117;
    border: none;
    color: #e6edf3;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    resize: vertical;
}

.cell-code:focus {
    outline: none;
}

.cell-output {
    padding: 12px;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
}

.cell-output.error {
    background: rgba(239, 68, 68, 0.1);
}

.output-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    display: block;
}

.cell-output pre {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
    color: var(--text-secondary);
}

.cell-output.error pre {
    color: var(--error);
}

/* Notebook toolbar and hints */
.notebook-toolbar {
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.notebook-hint {
    opacity: 0.7;
}

/* Cell type selector */
.cell-type-select {
    padding: 4px 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.8rem;
    cursor: pointer;
}

/* Cell type badges */
.cell-type {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.cell-type.code-type {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
}

.cell-type.markdown-type {
    background: rgba(99, 102, 241, 0.2);
    color: #818cf8;
}

/* Markdown cell input */
.cell-input.cell-markdown {
    background: var(--bg-secondary);
    color: var(--text-primary);
    min-height: 60px;
}

/* Rendered markdown cell */
.cell-markdown-rendered {
    padding: 16px;
    background: var(--bg-secondary);
    cursor: pointer;
}

.cell-markdown-rendered:hover {
    background: var(--bg-tertiary);
}

.cell-markdown-rendered p {
    margin: 0 0 8px;
}

.cell-markdown-rendered p:last-child {
    margin-bottom: 0;
}

/* Enhanced empty state */
.notebook-empty {
    padding: 40px 20px;
}

.notebook-empty .empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

.notebook-empty h3 {
    margin: 0 0 8px;
    color: var(--text-primary);
}

.notebook-empty p {
    margin: 0 0 20px;
}

.notebook-empty .empty-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* Notebook toggle button in header */
.notebook-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.notebook-toggle:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* Run all and clear buttons */
.notebook-btn.run-all {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

.notebook-btn.clear {
    color: var(--error);
}

.notebook-btn.clear:hover {
    background: var(--error);
    color: white;
    border-color: var(--error);
}

/* ==================== MOBILE RESPONSIVE ==================== */
@media (max-width: 768px) {

    /* General Layout */
    .app-container {
        flex-direction: column;
    }

    /* Sidebar */
    .sidebar {
        position: fixed;
        left: -280px;
        width: 280px;
        z-index: 1001;
    }

    .sidebar.open {
        left: 0;
    }

    /* Chat area */
    .chat-main {
        width: 100%;
        margin: 0;
    }

    /* Messages */
    .message {
        padding: 12px;
        flex-direction: column;
        gap: 8px;
    }

    .message-avatar {
        display: none;
    }

    .message-content {
        max-width: 100%;
    }

    .message-text {
        font-size: 0.9rem;
    }

    /* Input area */
    .input-wrapper {
        padding: 12px;
    }

    .input-container {
        padding: 8px 12px;
    }

    #messageInput {
        font-size: 16px;
        /* Prevents iOS zoom */
    }

    /* Code blocks */
    .code-block-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .code-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .run-in-notebook-btn,
    .copy-btn {
        padding: 4px 8px;
        font-size: 0.7rem;
    }

    .message-text pre code {
        font-size: 0.8rem;
        padding: 12px;
    }

    /* Quiz mobile */
    .quiz-container {
        padding: 12px;
    }

    .quiz-question {
        font-size: 1rem;
    }

    .quiz-option {
        padding: 10px 12px;
    }

    .quiz-navigation {
        flex-direction: row;
        gap: 8px;
    }

    .quiz-nav-btn {
        flex: 1;
        padding: 10px;
    }

    /* Flashcards mobile */
    .flashcard {
        min-height: 180px;
        padding: 16px;
    }

    .flashcard-front,
    .flashcard-back {
        font-size: 1rem;
    }

    /* Comparison table mobile */
    .comparison-container {
        flex-direction: column;
    }

    .comparison-col {
        width: 100%;
    }

    /* Timeline mobile */
    .timeline-item {
        padding-left: 20px;
    }

    .timeline-date {
        font-size: 0.8rem;
    }

    /* Charts mobile */
    .chart-wrapper {
        height: 250px;
    }

    /* Notebook panel mobile - full screen */
    .notebook-panel {
        width: 100vw;
        right: -100vw;
        min-width: unset;
    }

    .chat-main.notebook-active {
        display: none;
    }

    .notebook-header {
        flex-wrap: wrap;
        gap: 8px;
    }

    .notebook-actions {
        flex-wrap: wrap;
    }

    .cell-code,
    .cell-markdown {
        font-size: 0.8rem;
    }

    /* Generated images mobile */
    .generated-image-container {
        max-width: 100%;
    }

    .generated-image {
        max-width: 100%;
    }

    /* Welcome screen mobile */
    .welcome-content {
        padding: 16px;
    }

    .welcome-logo-inner svg {
        width: 36px;
        height: 36px;
    }

    .welcome-title {
        font-size: 1.5rem;
    }

    .feature-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .feature-card {
        padding: 12px;
    }

    /* Fullscreen modal mobile */
    .fullscreen-modal img {
        max-width: 95vw;
        max-height: 80vh;
    }

    .fullscreen-actions {
        flex-wrap: wrap;
        gap: 8px;
    }

    /* Citations mobile */
    .citations-container {
        gap: 8px;
    }

    .citation-card {
        padding: 10px;
    }
}

/* ==================== PIN LOGIN MODAL ==================== */
.pin-login-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.pin-login-content {
    background: linear-gradient(145deg, var(--bg-secondary), var(--bg-tertiary));
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 48px 40px;
    text-align: center;
    max-width: 360px;
    width: 90%;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.4s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.pin-login-logo {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    background: linear-gradient(135deg, var(--accent), #9333ea);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.pin-login-content h2 {
    font-size: 1.5rem;
    margin: 0 0 8px;
    color: var(--text-primary);
}

.pin-login-content p {
    color: var(--text-muted);
    margin: 0 0 24px;
}

.pin-input-container {
    margin-bottom: 20px;
}

.pin-input {
    width: 100%;
    padding: 16px;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1.5rem;
    text-align: center;
    letter-spacing: 0.5em;
    font-family: 'JetBrains Mono', monospace;
}

.pin-input:focus {
    outline: none;
    border-color: var(--accent);
}

.pin-login-btn {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, var(--accent), #9333ea);
    border: none;
    border-radius: 12px;
    color: white;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s;
}

.pin-login-btn:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.4);
}

.pin-error {
    color: var(--error);
    margin-top: 16px;
    font-size: 0.9rem;
    min-height: 1.2em;
}

/* ==================== COLAB NOTEBOOK PANEL ==================== */
.colab-panel {
    position: fixed;
    top: 0;
    right: -40vw;
    width: 40vw;
    min-width: 450px;
    max-width: 700px;
    height: 100vh;
    background: var(--bg-primary);
    border-left: 1px solid var(--border-color);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.4);
}

.colab-panel.open {
    right: 0;
}

.chat-main.notebook-active {
    margin-right: 40vw;
    transition: margin-right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.colab-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.colab-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 1rem;
}

.colab-toolbar {
    display: flex;
    gap: 8px;
    flex: 1;
}

.colab-add-btn {
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.colab-add-btn:hover,
.colab-add-btn.primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.colab-add-btn.text:hover {
    background: #6366f1;
    border-color: #6366f1;
}

.colab-actions {
    display: flex;
    gap: 8px;
}

.colab-btn {
    padding: 6px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.8rem;
}

.colab-btn.run-all {
    background: linear-gradient(135deg, #238636, #2ea043);
    color: white;
    border: none;
}

.colab-btn.save {
    background: var(--accent);
    color: white;
    border: none;
}

.colab-btn.clear:hover {
    background: var(--error);
    color: white;
}

.colab-close {
    padding: 6px 10px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
}

.colab-close:hover {
    color: var(--error);
}

.colab-hint {
    padding: 8px 16px;
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-size: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.colab-cells {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.colab-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
    padding: 40px;
}

.colab-empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

.colab-empty h3 {
    margin: 0 0 8px;
    color: var(--text-primary);
}

.colab-empty p {
    margin: 0 0 24px;
}

.colab-empty-actions {
    display: flex;
    gap: 12px;
}

/* Colab Cell */
.colab-cell {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    overflow: hidden;
}

.colab-cell.running {
    border-color: var(--accent);
}

.colab-cell.error {
    border-color: var(--error);
}

.colab-cell-gutter {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 8px;
    background: var(--bg-tertiary);
    border-right: 1px solid var(--border-color);
    gap: 8px;
}

.colab-run-btn {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #238636, #2ea043);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
}

.colab-run-btn:hover {
    transform: scale(1.1);
}

.colab-run-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.colab-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.colab-cell-num {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.colab-cell-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.colab-cell-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.colab-cell-type {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.colab-cell-type.code {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
}

.colab-cell-type.text {
    background: rgba(99, 102, 241, 0.2);
    color: #818cf8;
}

.colab-cell-actions button {
    background: transparent;
    border: none;
    cursor: pointer;
    opacity: 0.6;
}

.colab-cell-actions button:hover {
    opacity: 1;
}

.colab-textarea {
    width: 100%;
    min-height: 60px;
    padding: 12px;
    border: none;
    resize: none;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    background: #0d1117;
    color: #c9d1d9;
}

.colab-textarea.markdown {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.colab-textarea:focus {
    outline: none;
}

.colab-output {
    padding: 12px;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    max-height: 200px;
    overflow-y: auto;
}

.colab-output.error {
    background: rgba(239, 68, 68, 0.1);
}

.colab-output pre {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
    color: var(--text-secondary);
}

.colab-output.error pre {
    color: var(--error);
}

/* Mobile responsive for colab */
@media (max-width: 1200px) {
    .colab-panel {
        width: 50vw;
        right: -50vw;
    }

    .chat-main.notebook-active {
        margin-right: 50vw;
    }
}

@media (max-width: 768px) {
    .colab-panel {
        width: 100vw;
        right: -100vw;
        min-width: unset;
    }

    .chat-main.notebook-active {
        display: none;
    }

    .colab-header {
        padding: 10px;
    }

    .colab-textarea {
        font-size: 0.8rem;
    }
}

/* ==================== TOC FLOATING PANEL ==================== */
.toc-float-btn {
    position: fixed;
    right: 20px;
    top: 100px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: linear-gradient(135deg, var(--accent), #7c3aed);
    border: none;
    border-radius: 30px;
    color: white;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
    z-index: 998;
    transition: all 0.3s;
}

.toc-float-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

.toc-badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
}

.toc-panel {
    position: fixed;
    right: -360px;
    top: 50%;
    transform: translateY(-50%);
    width: 340px;
    max-height: 80vh;
    background: rgba(20, 20, 30, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: flex;
    flex-direction: column;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toc-panel.open {
    right: 20px;
}

.toc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.toc-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: var(--text-primary);
}

.toc-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px 8px;
}

.toc-close:hover {
    color: var(--error);
}

.toc-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.toc-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
}

.toc-empty .hint {
    font-size: 0.85rem;
    opacity: 0.7;
}

.toc-tree {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toc-phase {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    overflow: hidden;
}

.toc-phase.active {
    background: rgba(99, 102, 241, 0.1);
}

.toc-phase.done {
    opacity: 0.7;
}

.toc-phase-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-primary);
    transition: background 0.2s;
}

.toc-phase-header:hover {
    background: rgba(255, 255, 255, 0.05);
}

.toc-expand-icon {
    font-size: 0.7rem;
    color: var(--text-muted);
    width: 16px;
}

.toc-check {
    color: var(--success);
    margin-left: auto;
}

.toc-phase-content {
    padding: 0 8px 12px;
}

.toc-subphase {
    margin-bottom: 8px;
}

.toc-subphase-name {
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 4px 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.toc-topics {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.toc-topic {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.toc-topic:hover {
    background: rgba(255, 255, 255, 0.05);
}

.toc-topic.current {
    background: linear-gradient(135deg, var(--accent), #7c3aed);
    color: white;
}

.toc-topic.completed {
    color: var(--text-muted);
}

.toc-topic-icon {
    font-size: 0.7rem;
    width: 14px;
    text-align: center;
}

.toc-topic.completed .toc-topic-icon {
    color: var(--success);
}

.toc-topic.current .toc-topic-icon {
    color: white;
}

.toc-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 16px;
}

.toc-progress {
    margin-bottom: 12px;
}

.toc-progress span {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: block;
    margin-bottom: 8px;
}

.toc-progress-bar {
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.toc-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #7c3aed);
    border-radius: 2px;
    transition: width 0.3s;
}

.toc-nav {
    display: flex;
    gap: 8px;
}

.toc-nav-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
}

.toc-nav-btn.prev {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.toc-nav-btn.prev:hover:not(:disabled) {
    background: var(--bg-secondary);
}

.toc-nav-btn.next {
    background: linear-gradient(135deg, #238636, #2ea043);
    color: white;
}

.toc-nav-btn.next:hover:not(:disabled) {
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.4);
}

.toc-nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.toc-inline-notice {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(124, 58, 237, 0.1));
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 8px;
    padding: 12px 16px;
    color: var(--accent);
    font-size: 0.9rem;
}

/* TOC Mobile */
@media (max-width: 768px) {
    .toc-float-btn {
        right: 10px;
        top: auto;
        bottom: 100px;
        padding: 8px 14px;
    }

    .toc-panel {
        right: -100vw;
        width: 100vw;
        max-height: 60vh;
        top: auto;
        bottom: 0;
        transform: none;
        border-radius: 16px 16px 0 0;
    }

    .toc-panel.open {
        right: 0;
    }
}

/* ==================== TOOLKIT MENU ==================== */
.toolkit-container {
    position: relative;
}

.toolkit-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.toolkit-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    transform: scale(1.05);
}

.toolkit-menu {
    position: absolute;
    bottom: 50px;
    left: 0;
    width: 200px;
    background: rgba(20, 20, 30, 0.98);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.2s;
    z-index: 100;
}

.toolkit-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.toolkit-tool {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.9rem;
    transition: all 0.15s;
}

.toolkit-tool:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.toolkit-tool.active {
    background: rgba(99, 102, 241, 0.2);
    color: var(--accent);
}

.toolkit-tool.active::after {
    content: '✓';
    margin-left: auto;
    color: var(--success);
    font-size: 0.8rem;
}

/* Active Tools Badges */
.active-tools {
    display: none;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 8px;
}

.active-tool-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(124, 58, 237, 0.2));
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--accent);
    cursor: pointer;
    transition: all 0.2s;
}

.active-tool-badge:hover {
    background: rgba(99, 102, 241, 0.3);
}

.badge-close {
    font-size: 0.9rem;
    opacity: 0.6;
}

.badge-close:hover {
    opacity: 1;
}