
.thinking-box {
    position: relative !important;
    margin-top: 4px; /* Increased space below the last user message */
    background: transparent;
    padding: 16px;
    border-radius: 12px;
    z-index: 0;
    max-width: 100%;
  }
  
  
  .thinking-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    cursor: pointer;
    user-select: none;
}

.thinking-dots {
    display: flex;
    gap: 4px;
    margin-right: 8px;
}

.dot {
    width: 5px;
    height: 5px;
    background: #9ca3af;
    border-radius: 50%;
    animation: pulse 1.5s ease-in-out infinite;
}

.dot:nth-child(1) { animation-delay: 0s; }
.dot:nth-child(2) { animation-delay: 0.3s; }
.dot:nth-child(3) { animation-delay: 0.6s; }

@keyframes pulse {
    0%, 60%, 100% {
        opacity: 0.4;
        transform: scale(1);
    }
    30% {
        opacity: 1;
        transform: scale(1.2);
    }
}

.thinking-title {
    color: #1a1a1a;
    font-size: 16px;
    font-weight: 500;
}

.thinking-time {
    color: #6b7280;
    font-size: 16px;
    margin-left: auto;
    font-variant-numeric: tabular-nums;
}

.collapse-btn {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 6px;
    margin-left: 12px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.collapse-btn:hover {
    color: #374151;
    background: transparent;
}

.collapse-btn svg {
    transition: transform 0.3s ease;
}

.thinking-box.collapsed .collapse-btn svg {
    transform: rotate(-90deg);
}

/* Perfect Sync Container */
.content-container {
    position: relative;
    height: 320px;
    overflow: hidden;
    display: flex;
    gap: 16px;
}

.thinking-box.collapsed .content-container {
    height: 80px;
}

/* Synchronized Progress Track */
.progress-track {
    position: relative;
    width: 8px;
    height: 100%;
    flex-shrink: 0;
    z-index: 10;
}

/* Continuous Growing Line */
.progress-line {
    position: absolute;
    left: 4px;
    top: 0;
    width: 2px;
    height: 0;
    background: linear-gradient(to bottom, #10b981, #3b82f6);
    box-shadow: 0 0 4px rgba(16, 185, 129, 0.2);
    border-radius: 1px;
    transition: height 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Synchronized Circles */
.sync-circle {
    position: absolute;
    left: 2px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #e5e7eb;
    border: 1px solid #d1d5db;
    opacity: 0;
    transform: scale(0);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sync-circle.appearing {
    opacity: 1;
    transform: scale(1);
}

.sync-circle.writing {
    background: #3b82f6;
    border-color: #3b82f6;
    box-shadow: 0 0 16px rgba(59, 130, 246, 0.4);
    animation: sync-glow 1.2s ease-in-out infinite;
}

.sync-circle.completed {
    background: #10b981;
    border-color: #10b981;
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.3);
    animation: none;
}

@keyframes sync-glow {
    0%, 100% { 
        box-shadow: 0 0 16px rgba(59, 130, 246, 0.4);
        transform: scale(1);
    }
    50% { 
        box-shadow: 0 0 24px rgba(59, 130, 246, 0.6);
        transform: scale(1.15);
    }
}

/* Perfect Content Centering */
.thinking-content {
    flex: 1;
    position: relative;
    height: 100%;
    overflow: hidden;
}

.content-viewport {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    overflow: hidden;
}

.content-stream {
    width: 100%;
    transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform;
}

.sentence-group {
    margin-bottom: 32px;
    opacity: 0;
    transform: translateY(40px);
    transition: all 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    color: #4b5563;
    font-size: 13px;
    line-height: 1.6;
    letter-spacing: -0.03em;
    position: relative;
    min-height: 24px;
}

.sentence-group.synced {
    opacity: 1;
    transform: translateY(0);
}

.sentence-group.current {
    color: #111827;
    opacity: 1;
    z-index: 5;
}

.sentence-group.completed {
    opacity: 0.6;
    color: #6b7280;
}

.sentence-group.faded {
    opacity: 0.3;
    color: #9ca3af;
}

.sentence-group p {
    margin: 0 0 8px 0;
    white-space: pre-wrap;
}

.sentence-group p:last-child {
    margin-bottom: 0;
}

/* Ultra-Smooth Character Animation */
.char {
    opacity: 0;
    display: inline-block;
    animation: ultraSmooth 0.03s ease-out forwards;
}

@keyframes ultraSmooth {
    from { 
        opacity: 0; 
        transform: translateY(3px);
    }
    to { 
        opacity: 1; 
        transform: translateY(0);
    }
}

/* Enhanced Fade Mask */
.content-viewport::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        to bottom,
        #ffffff 0%,
        transparent 12%,
        transparent 88%,
        #ffffff 100%
    );
    pointer-events: none;
    z-index: 2;
}

/* 1. Hide the animation progress track as it's no longer needed. */
.thinking-box.completed-state .progress-track {
    display: none;
}

/* 2. Make the main content viewport scrollable. */
.thinking-box.completed-state .content-viewport {
    overflow-y: auto; /* This is the key change to enable scrolling. */
    align-items: flex-start; /* Aligns content to the top for natural scrolling. */
}

/* 3. Remove the fade overlay that hides the top/bottom of the scrollable area. */
.thinking-box.completed-state .content-viewport::before {
    display: none;
}