/* ═══════════════════════════════════════════════════════════════════════════
   TWIN EVOLUTION PAGE STYLES
   DSP-06 Digital Twin Emotional Evolution Frontend
   ═══════════════════════════════════════════════════════════════════════════ */

/* Enable scrolling for this page */
body.twin-evolution-page {
    overflow-y: auto !important;
    overflow-x: hidden;
    height: auto;
    min-height: 100vh;
}

body.twin-evolution-page #app {
    height: auto;
    min-height: 100vh;
}

/* Page Layout */
.twin-evolution-page {
    background: linear-gradient(135deg, #0a0a12 0%, #0d1020 50%, #0a0a12 100%);
    min-height: 100vh;
}

/* Full viewport width like the chat page. Keep simple single-column
   stack — sections stretch to fill, but narrow-content sections
   (TEI ring, avatar) self-center inside. */
.twin-container {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 1.5rem clamp(1rem, 4vw, 3rem);
    display: block;
}

.tei-display {
    max-width: 460px;
    margin-left: auto;
    margin-right: auto;
}

@media (max-width: 900px) {
    .twin-container { padding: 1rem 1.25rem; }
}

@media (max-width: 600px) {
    .twin-container { padding: 0.75rem; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   TWIN AVATAR SECTION
   ═══════════════════════════════════════════════════════════════════════════ */

.twin-avatar-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 3rem 1rem;
    position: relative;
    overflow: hidden;
}

.twin-glow {
    position: absolute;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(100, 180, 160, 0.15) 0%, transparent 70%);
    border-radius: 50%;
    animation: pulse-glow 4s ease-in-out infinite;
    pointer-events: none;
}

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

.twin-avatar {
    position: relative;
    width: 160px;
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-core {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, rgba(100, 180, 160, 0.3) 0%, rgba(80, 140, 180, 0.2) 100%);
    border: 2px solid rgba(100, 180, 160, 0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    animation: core-pulse 3s ease-in-out infinite;
}

@keyframes core-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.avatar-symbol {
    font-size: 2rem;
    color: #64b4a0;
    text-shadow: 0 0 20px rgba(100, 180, 160, 0.5);
}

.avatar-rings {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.ring {
    position: absolute;
    border: 1px solid rgba(100, 180, 160, 0.2);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.ring-1 {
    width: 100px;
    height: 100px;
    animation: ring-rotate 20s linear infinite;
}

.ring-2 {
    width: 130px;
    height: 130px;
    animation: ring-rotate 30s linear infinite reverse;
}

.ring-3 {
    width: 160px;
    height: 160px;
    animation: ring-rotate 40s linear infinite;
}

@keyframes ring-rotate {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Stage styles for avatar */
.twin-avatar.stage-1 .avatar-core { border-color: rgba(150, 150, 150, 0.5); }
.twin-avatar.stage-2 .avatar-core { border-color: rgba(180, 160, 100, 0.5); }
.twin-avatar.stage-3 .avatar-core { border-color: rgba(100, 180, 160, 0.5); }
.twin-avatar.stage-4 .avatar-core { border-color: rgba(100, 160, 200, 0.5); }
.twin-avatar.stage-5 .avatar-core { border-color: rgba(160, 100, 180, 0.5); }
.twin-avatar.stage-6 .avatar-core { border-color: rgba(200, 140, 100, 0.5); }
.twin-avatar.stage-7 .avatar-core { 
    border-color: rgba(255, 200, 100, 0.7);
    box-shadow: 0 0 30px rgba(255, 200, 100, 0.3);
}

.twin-stage-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #64b4a0;
    margin: 1.5rem 0 0.25rem 0;
    text-align: center;
}

.twin-stage-name {
    font-family: 'Crimson Pro', serif;
    font-size: 1.1rem;
    font-style: italic;
    color: var(--text-secondary);
    margin: 0;
    text-align: center;
}

/* ═══════════════════════════════════════════════════════════════════════════
   TEI SCORE SECTION
   ═══════════════════════════════════════════════════════════════════════════ */

.tei-section {
    padding: 1rem;
    display: flex;
    justify-content: center;
}

.tei-display {
    text-align: center;
}

.tei-score-container {
    position: relative;
    width: 180px;
    height: 180px;
    margin: 0 auto 1rem;
}

.tei-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.tei-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.1);
    stroke-width: 12;
}

.tei-fill {
    fill: none;
    stroke: url(#teiGradient);
    stroke-width: 12;
    stroke-linecap: round;
    stroke-dasharray: 565;
    stroke-dashoffset: 565;
    transition: stroke-dashoffset 1s ease;
}

.tei-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.tei-number {
    display: block;
    font-size: 2.5rem;
    font-weight: 600;
    color: #64b4a0;
    line-height: 1;
}

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

.tei-explanation {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   VECTORS SECTION
   ═══════════════════════════════════════════════════════════════════════════ */

.vectors-section {
    padding: 1.5rem 0;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 500;
    color: #e8e8e8;
    margin: 0 0 1rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.vectors-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.vector-card {
    background: var(--bg-card, rgba(255, 255, 255, 0.03));
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
    border-radius: 12px;
    padding: 1.1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    transition: border-color 0.15s, transform 0.15s;
}
.vector-card:hover {
    border-color: var(--accent, #C4A77D);
    transform: translateY(-2px);
}

.vector-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.vector-icon {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--accent, #C4A77D);
    flex-shrink: 0;
}
.vector-icon svg { width: 20px; height: 20px; }

.vector-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    gap: 2px;
}

.vector-name {
    font-size: 0.95rem;
    color: var(--text-primary);
    font-weight: 500;
    font-family: var(--font-display, 'Crimson Pro', serif);
    letter-spacing: 0.01em;
}

.vector-abbr {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.vector-bar {
    height: 6px;
    background: var(--border-subtle, rgba(255, 255, 255, 0.08));
    border-radius: 999px;
    overflow: hidden;
}

.vector-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.6s cubic-bezier(0.25, 0.1, 0.25, 1);
    width: 0%;
    background: var(--accent, #C4A77D);
}

/* Per-vector tints using the elemental palette */
.vector-card[data-vector="esv"] .vector-fill { background: var(--water, #5B8FA8); }
.vector-card[data-vector="ccv"] .vector-fill { background: var(--air, #87A889); }
.vector-card[data-vector="crv"] .vector-fill { background: var(--ether, #9B8AA8); }
.vector-card[data-vector="idv"] .vector-fill { background: var(--accent, #C4A77D); }

.vector-value {
    font-size: 1.35rem;
    font-weight: 500;
    color: var(--text-primary);
    font-family: var(--font-display, 'Crimson Pro', serif);
    font-variant-numeric: tabular-nums;
    margin-left: auto;
}

.vector-description {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.45;
    margin: 0;
}

.vector-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0;
    padding: 0.4rem 0.6rem;
    background: var(--bg-dark, rgba(0,0,0,0.2));
    border-radius: 6px;
    border-left: 2px solid var(--accent, #C4A77D);
    min-height: 1.4rem;
}
.vector-hint:empty { display: none; }

/* ═══════════════════════════════════════════════════════════════════════════
   STAGES TIMELINE
   ═══════════════════════════════════════════════════════════════════════════ */

.journey-section {
    padding: 1.5rem 0;
}

.stages-timeline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    position: relative;
}

/* Removed: legacy middle rail was drawing a duplicate line behind the
   per-marker rails. The per-marker ::after rules are the source of truth. */

.stage-node {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
}

.stage-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(30, 30, 40, 1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    transition: all 0.3s ease;
}

.stage-node.completed .stage-dot {
    background: rgba(100, 180, 160, 0.2);
    border-color: #64b4a0;
    color: #64b4a0;
}

.stage-node.current .stage-dot {
    background: linear-gradient(135deg, rgba(100, 180, 160, 0.3) 0%, rgba(80, 140, 180, 0.2) 100%);
    border-color: #64b4a0;
    color: #64b4a0;
    box-shadow: 0 0 15px rgba(100, 180, 160, 0.3);
    animation: current-pulse 2s ease-in-out infinite;
}

@keyframes current-pulse {
    0%, 100% { box-shadow: 0 0 15px rgba(100, 180, 160, 0.3); }
    50% { box-shadow: 0 0 25px rgba(100, 180, 160, 0.5); }
}

.stage-node.locked .stage-dot {
    opacity: 0.5;
}

.stage-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    text-align: center;
    max-width: 60px;
}

.stage-node.current .stage-label,
.stage-node.completed .stage-label {
    color: var(--text-secondary);
}

/* ═══════════════════════════════════════════════════════════════════════════
   STAGE DETAILS CARD
   ═══════════════════════════════════════════════════════════════════════════ */

.stage-details-section {
    padding: 1rem 0;
}

.card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 1.5rem;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 500;
    color: #e8e8e8;
    margin: 0 0 1rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stage-description {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0 0 1.5rem 0;
}

.stage-capabilities h4,
.next-stage-preview h4 {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    margin: 0 0 0.75rem 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.capabilities-list {
    list-style: none;
    padding: 0;
    margin: 0 0 1.5rem 0;
}

.capabilities-list li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.capabilities-list li:last-child {
    border-bottom: none;
}

.capabilities-list li::before {
    content: '✓';
    color: #64b4a0;
    font-weight: bold;
}

.next-stage-preview {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    padding: 1rem;
    border: 1px dashed rgba(255, 255, 255, 0.1);
}

.next-stage-name {
    font-size: 1rem;
    color: #e8e8e8;
    margin: 0 0 0.75rem 0;
}

.unlock-progress {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.unlock-bar {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.unlock-fill {
    height: 100%;
    background: linear-gradient(90deg, #64b4a0, #508cb4);
    border-radius: 3px;
    transition: width 0.5s ease;
    width: 0%;
}

.unlock-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════════════════════
   HISTORY TIMELINE
   ═══════════════════════════════════════════════════════════════════════════ */

.history-section {
    padding: 1.5rem 0;
}

.history-timeline {
    position: relative;
    padding-left: 2rem;
}

.history-timeline::before {
    content: '';
    position: absolute;
    left: 0.5rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: rgba(255, 255, 255, 0.1);
}

.history-event {
    position: relative;
    padding: 1rem;
    margin-bottom: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
}

.history-event::before {
    content: '';
    position: absolute;
    left: -1.5rem;
    top: 1.25rem;
    width: 10px;
    height: 10px;
    background: #64b4a0;
    border-radius: 50%;
    border: 2px solid #0a0a12;
}

.event-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.event-type {
    font-size: 0.85rem;
    font-weight: 500;
    color: #e8e8e8;
}

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

.event-details {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
    font-style: italic;
}

/* ═══════════════════════════════════════════════════════════════════════════
   COMPANION SYNC
   ═══════════════════════════════════════════════════════════════════════════ */

.sync-section {
    padding: 1rem 0 2rem;
}

.sync-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.sync-companion {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    transition: all 0.2s ease;
}

.sync-companion.active {
    background: rgba(100, 180, 160, 0.1);
    border: 1px solid rgba(100, 180, 160, 0.2);
}

.sync-emoji {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.sync-name {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.sync-status {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.sync-companion.active .sync-status {
    color: #64b4a0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   EVOLUTION NOTIFICATION
   ═══════════════════════════════════════════════════════════════════════════ */

.evolution-notification {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: linear-gradient(135deg, rgba(100, 180, 160, 0.2) 0%, rgba(80, 140, 180, 0.15) 100%);
    border: 1px solid rgba(100, 180, 160, 0.4);
    border-radius: 16px;
    padding: 1rem 1.5rem;
    opacity: 0;
    transition: all 0.5s ease;
    z-index: 100;
}

.evolution-notification.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.notification-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.notification-icon {
    font-size: 2rem;
    animation: sparkle 1s ease infinite;
}

@keyframes sparkle {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.2) rotate(10deg); }
}

.notification-text {
    display: flex;
    flex-direction: column;
}

.notification-text strong {
    color: #64b4a0;
    font-size: 1rem;
}

.notification-text span {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .vectors-grid {
        grid-template-columns: 1fr;
    }

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

    .stages-timeline {
        overflow-x: auto;
        padding-bottom: 1rem;
    }

    .stage-node {
        min-width: 60px;
    }
}

@media (max-width: 480px) {
    .twin-container {
        padding: 0.75rem;
    }

    .twin-avatar-section {
        padding: 2rem 1rem;
    }

    .twin-avatar {
        width: 120px;
        height: 120px;
    }

    .avatar-core {
        width: 60px;
        height: 60px;
    }

    .ring-1 { width: 80px; height: 80px; }
    .ring-2 { width: 100px; height: 100px; }
    .ring-3 { width: 120px; height: 120px; }

    .tei-score-container {
        width: 150px;
        height: 150px;
    }

    .tei-number {
        font-size: 2rem;
    }

    .sync-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }

    .sync-companion {
        padding: 0.75rem 0.5rem;
    }

    .sync-name {
        font-size: 0.7rem;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   TWIN EVOLUTION ENHANCED STYLES v2.0
   ═══════════════════════════════════════════════════════════════════════════ */

/* Stage Markers */
.stage-marker {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    margin-bottom: 0.5rem;
    transition: all 0.3s ease;
}

.stage-marker.current {
    background: linear-gradient(135deg, rgba(100, 180, 160, 0.15), rgba(80, 140, 180, 0.1));
    border: 1px solid rgba(100, 180, 160, 0.3);
}

.stage-marker.completed {
    background: rgba(74, 222, 128, 0.05);
}

.stage-marker.locked {
    opacity: 0.5;
}

.stage-dot {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: var(--text-primary);
    flex-shrink: 0;
}

.stage-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.stage-num {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.stage-name {
    font-size: 0.9rem;
    color: var(--text-primary);
}

.stage-threshold {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 8px;
    border-radius: 10px;
}

/* History Events */
.history-event {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    margin-bottom: 0.75rem;
    transition: all 0.3s ease;
}

.history-event:hover {
    background: rgba(255, 255, 255, 0.05);
}

.history-event.stage_reached {
    border-left: 3px solid #4ade80;
}

.history-event.vector_increase {
    border-left: 3px solid #60a5fa;
}

.history-event.companion_sync {
    border-left: 3px solid #a78bfa;
}

.history-event.milestone {
    border-left: 3px solid #fbbf24;
}

.history-event.twin_initialized {
    border-left: 3px solid #f472b6;
}

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

.event-content {
    flex: 1;
}

.event-title {
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.event-trigger {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: 0.5rem;
}

.event-change {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.change-value {
    font-size: 0.85rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 6px;
}

.change-value.positive {
    background: rgba(74, 222, 128, 0.2);
    color: #4ade80;
}

.change-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.companion-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 10px;
    border-radius: 15px;
}

.sync-level {
    font-size: 0.8rem;
    color: #4ade80;
}

.event-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Companion Sync Grid */
.sync-companion {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    margin-bottom: 0.5rem;
}

.sync-companion .companion-emoji {
    font-size: 1.5rem;
}

.sync-companion .companion-name {
    min-width: 70px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.sync-bar {
    flex: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.sync-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.sync-value {
    min-width: 40px;
    text-align: right;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.sync-interactions {
    font-size: 0.7rem;
    color: var(--text-muted);
    min-width: 60px;
    text-align: right;
}

/* Capabilities List */
.capabilities-list {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0;
}

.capabilities-list li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.capabilities-list li:last-child {
    border-bottom: none;
}

.cap-check {
    color: #4ade80;
    font-size: 0.9rem;
}

/* Evolution Notification */
.evolution-notification {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, rgba(100, 180, 160, 0.95), rgba(80, 140, 180, 0.95));
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 1rem 1.5rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    transition: bottom 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 1000;
}

.evolution-notification.show {
    bottom: 2rem;
}

.notification-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.notification-icon {
    font-size: 2rem;
}

.notification-text {
    display: flex;
    flex-direction: column;
}

.notification-text strong {
    font-size: 1rem;
    color: var(--text-primary);
}

.notification-text span {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Vector Cards Enhancement */
.vector-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

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

.vector-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.vector-name {
    font-size: 0.8rem;
    color: var(--text-primary);
}

.vector-abbr {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

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

.vector-fill {
    height: 100%;
    background: linear-gradient(90deg, #64b4a0, #508cb4);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.vector-value {
    min-width: 45px;
    text-align: right;
    font-size: 0.9rem;
    font-weight: 600;
    color: #64b4a0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   ENHANCED STATS SECTION (DSP-09 Integration)
   ═══════════════════════════════════════════════════════════════════════════ */

.enhanced-stats-section {
    margin-top: 2rem;
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 600px) {
    .enhanced-stats-section {
        grid-template-columns: 1fr 1fr;
    }
}

/* Pattern Insights */
#patternInsights {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 1.25rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.insight-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

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

.insight-icon {
    color: #a064b4;
    font-size: 0.9rem;
    flex-shrink: 0;
    margin-top: 0.15rem;
}

.insight-text {
    color: #cbd5e1;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Emotional State Indicator */
#emotionalStateIndicator {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.state-badge {
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.state-label {
    color: #94a3b8;
    font-size: 0.9rem;
}

/* Growth Metrics */
#growthMetrics {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 1.25rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.metric-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.metric-row:last-child {
    margin-bottom: 0;
}

.metric-label {
    min-width: 90px;
    font-size: 0.85rem;
    color: #94a3b8;
}

.metric-bar {
    flex: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.metric-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #81C784);
    border-radius: 4px;
    transition: width 0.6s ease;
}

.metric-fill.growth {
    background: linear-gradient(90deg, #2196F3, #64B5F6);
}

.metric-fill.resilience {
    background: linear-gradient(90deg, #9C27B0, #BA68C8);
}

/* Mirror Guidance */
#mirrorGuidance {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 1.25rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.guidance-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

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

.guidance-label {
    color: #94a3b8;
    font-size: 0.85rem;
}

.guidance-value {
    color: #64b4a0;
    font-weight: 500;
    font-size: 0.9rem;
    text-transform: capitalize;
}

/* ═══════════════════════════════════════════════════════════════════════════
   NEXT-STAGE ACTIONS (C)
   ═══════════════════════════════════════════════════════════════════════════ */

.next-stage-actions {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
}

.next-stage-actions .actions-lede {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0 0 0.6rem 0;
    line-height: 1.5;
}

.next-stage-actions .actions-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.next-stage-actions .actions-list li {
    font-size: 0.85rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-card, rgba(255,255,255,0.04));
    border: 1px solid var(--border-color, rgba(255,255,255,0.08));
    border-radius: 8px;
}

.action-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent, #C4A77D);
    flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   COMPANION RECOMMENDATIONS (D)
   ═══════════════════════════════════════════════════════════════════════════ */

.recommendations-section { padding: 1.5rem 0; }

.recommendations-lede {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0 0 1.25rem 0;
    line-height: 1.5;
}

.companion-recs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.companion-rec {
    display: flex;
    gap: 1rem;
    padding: 1rem 1.1rem;
    background: var(--bg-elevated, rgba(255,255,255,0.04));
    border: 1px solid var(--border-color, rgba(255,255,255,0.08));
    border-radius: 12px;
    transition: border-color 0.2s, transform 0.2s;
}
.companion-rec:hover {
    border-color: var(--accent, #C4A77D);
    transform: translateY(-2px);
}

.companion-rec-icon {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.companion-rec-icon svg {
    width: 32px;
    height: 32px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.companion-rec-body {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 0;
}

.companion-rec-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.companion-rec-name {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    font-family: var(--font-display, 'Crimson Pro', serif);
}

.companion-rec-status {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.companion-rec-reason {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.45;
    margin: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   TEI TREND SPARKLINE (B)
   ═══════════════════════════════════════════════════════════════════════════ */

.tei-trend {
    margin-top: 1.25rem;
    padding: 0.75rem 1rem;
    background: var(--bg-card, rgba(255,255,255,0.03));
    border: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
    border-radius: 10px;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
}

.tei-sparkline {
    width: 100%;
    height: 60px;
    display: block;
}

.tei-trend-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.4rem;
    font-size: 0.75rem;
}

.tei-trend-label {
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.tei-trend-value {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* ═══════════════════════════════════════════════════════════════════════════
   COMPREHENSIVE RESPONSIVE BREAKPOINTS
   ═══════════════════════════════════════════════════════════════════════════ */

/* Vectors grid: 4 cols on wide, 2 on tablet, 1 on phone */
@media (min-width: 1000px) {
    .vectors-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 640px) and (max-width: 999px) {
    .vectors-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 639px) {
    .vectors-grid { grid-template-columns: 1fr; gap: 0.6rem; }
    .vector-card { padding: 0.9rem 1rem; }
    .vector-value { font-size: 1.15rem; }
}

/* Companion sync grid responsive */
@media (min-width: 768px) {
    #syncGrid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1100px) {
    #syncGrid { grid-template-columns: repeat(6, 1fr); }
}

/* Companion recommendations: auto-fit already in place, just tune minmax */
@media (max-width: 639px) {
    .companion-recs-grid { grid-template-columns: 1fr; }
    .companion-rec { padding: 0.85rem 0.95rem; gap: 0.75rem; }
}

/* Stages timeline: snap to horizontal scroll on narrow screens */
@media (max-width: 800px) {
    .stages-timeline {
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 1rem;
    }
    .stage-node {
        min-width: 80px;
        scroll-snap-align: start;
    }
}

/* TEI ring scales down on small screens */
@media (max-width: 600px) {
    .tei-score-container { width: 140px; height: 140px; }
    .tei-number { font-size: 2rem; }
    .tei-bg, .tei-fill { stroke-width: 10; }
    .tei-trend { max-width: 100%; }
}

/* Avatar scales on small screens */
@media (max-width: 600px) {
    .twin-avatar-section { padding: 2rem 0.5rem; }
    .twin-avatar { width: 120px; height: 120px; }
    .avatar-core { width: 60px; height: 60px; }
    .ring-1 { width: 80px; height: 80px; }
    .ring-2 { width: 100px; height: 100px; }
    .ring-3 { width: 120px; height: 120px; }
    .twin-stage-title { font-size: 1.25rem; }
}

/* Growth metrics + evolution history stack cleanly */
@media (max-width: 640px) {
    .metric-row { grid-template-columns: 90px 1fr; gap: 0.5rem; }
    .card-title { font-size: 1rem; }
    .section-title { font-size: 1rem; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   ENTRANCE + VALUE ANIMATIONS
   ═══════════════════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: no-preference) {
    /* Cards fade in and slide up, staggered */
    .vector-card,
    .companion-rec,
    .sync-companion,
    .timeline-event,
    .insight-item,
    .recommendations-section .card,
    .enhanced-stats-section .card,
    .stage-details .card {
        opacity: 0;
        transform: translateY(14px);
        animation: twin-card-in 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
    }

    .vectors-grid > .vector-card:nth-child(1) { animation-delay: 0.05s; }
    .vectors-grid > .vector-card:nth-child(2) { animation-delay: 0.10s; }
    .vectors-grid > .vector-card:nth-child(3) { animation-delay: 0.15s; }
    .vectors-grid > .vector-card:nth-child(4) { animation-delay: 0.20s; }

    .companion-recs-grid > .companion-rec:nth-child(1) { animation-delay: 0.10s; }
    .companion-recs-grid > .companion-rec:nth-child(2) { animation-delay: 0.18s; }
    .companion-recs-grid > .companion-rec:nth-child(3) { animation-delay: 0.26s; }

    #syncGrid > .sync-companion:nth-child(1) { animation-delay: 0.05s; }
    #syncGrid > .sync-companion:nth-child(2) { animation-delay: 0.10s; }
    #syncGrid > .sync-companion:nth-child(3) { animation-delay: 0.15s; }
    #syncGrid > .sync-companion:nth-child(4) { animation-delay: 0.20s; }
    #syncGrid > .sync-companion:nth-child(5) { animation-delay: 0.25s; }
    #syncGrid > .sync-companion:nth-child(6) { animation-delay: 0.30s; }

    @keyframes twin-card-in {
        to { opacity: 1; transform: translateY(0); }
    }

    /* Vector fill & sync bar: ease-out fill, accentuated */
    .vector-fill {
        transition: width 1.2s cubic-bezier(0.25, 0.1, 0.25, 1);
    }
    .sync-fill,
    .metric-fill,
    .unlock-fill {
        transition: width 1.2s cubic-bezier(0.25, 0.1, 0.25, 1);
    }

    /* Numeric value count-up effect via a subtle scale pulse when updated */
    .vector-value.updated,
    .tei-number.updated {
        animation: value-pulse 0.5s ease;
    }
    @keyframes value-pulse {
        0% { transform: scale(1); color: var(--text-primary); }
        50% { transform: scale(1.08); color: var(--accent, #C4A77D); }
        100% { transform: scale(1); color: var(--text-primary); }
    }

    /* Sparkline draws in */
    #teiSparkline path {
        animation: spark-draw 0.9s ease-out both;
    }
    @keyframes spark-draw {
        from { opacity: 0; }
        to { opacity: 1; }
    }

    /* Stage journey: pulse the current stage */
    .stage-node.active {
        animation: stage-pulse 2.4s ease-in-out infinite;
    }
    @keyframes stage-pulse {
        0%, 100% { box-shadow: 0 0 0 0 rgba(196, 167, 125, 0); }
        50% { box-shadow: 0 0 0 10px rgba(196, 167, 125, 0); box-shadow: 0 0 20px rgba(196, 167, 125, 0.25); }
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   STAGE DOTS (redesigned)
   ═══════════════════════════════════════════════════════════════════════════ */

.stage-dot {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-elevated, #1a1a24);
    border: 2px solid var(--border-color, #3a3a42);
    color: var(--text-muted);
    transition: border-color 0.2s, background 0.2s, color 0.2s;
    flex-shrink: 0;
}
.stage-dot svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.stage-marker.completed .stage-dot {
    background: rgba(196, 167, 125, 0.12);
    border-color: var(--accent, #C4A77D);
    color: var(--accent, #C4A77D);
}

.stage-marker.current .stage-dot {
    background: var(--accent, #C4A77D);
    border-color: var(--accent, #C4A77D);
    color: var(--bg-dark, #0a0a0f);
    box-shadow: 0 0 0 4px rgba(196, 167, 125, 0.18);
}
.stage-marker.current .stage-dot svg { stroke-width: 2.25; }

.stage-marker.locked .stage-dot {
    opacity: 0.45;
}

/* ═══════════════════════════════════════════════════════════════════════════
   AVATAR SYMBOL (Lucide instead of emoji)
   ═══════════════════════════════════════════════════════════════════════════ */

.avatar-symbol {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    color: var(--accent, #C4A77D);
}
.avatar-symbol svg {
    width: 32px;
    height: 32px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ═══════════════════════════════════════════════════════════════════════════
   HISTORY EVENT ICONS (now Lucide)
   ═══════════════════════════════════════════════════════════════════════════ */

.event-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(196, 167, 125, 0.1);
    color: var(--accent, #C4A77D);
    flex-shrink: 0;
}
.event-icon svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.history-event.safety_event .event-icon { background: rgba(239,68,68,0.1); color: #ef4444; }
.history-event.ritual_completed .event-icon { background: rgba(196,167,125,0.12); }
.history-event.breakthrough .event-icon { background: rgba(139,92,246,0.1); color: #a78bfa; }

.companion-badge [data-icon] svg { width: 14px; height: 14px; vertical-align: -2px; }

/* ═══════════════════════════════════════════════════════════════════════════
   REDESIGN — v3
   A tighter, more deliberate visual hierarchy. Late in the stylesheet so
   these rules override earlier ones without touching the legacy CSS above.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Hero band: avatar + TEI side-by-side on wide, stacked on mobile ── */

@media (min-width: 900px) {
    .twin-avatar-section,
    .tei-section {
        padding: 0;
        background: none;
    }

    /* Flip the two hero sections into a single flex row by floating them
       into the same rhythm with negative-margin overlap. */
    .twin-avatar-section + .tei-section {
        margin-top: -2rem;
    }
}

/* Avatar section cleanup */
.twin-avatar-section {
    padding: 2.5rem 1rem 1.5rem;
    background: radial-gradient(ellipse at center top,
        rgba(196, 167, 125, 0.08) 0%,
        transparent 70%);
}

.twin-stage-title {
    font-family: var(--font-display, 'Crimson Pro', serif);
    font-size: 2rem;
    font-weight: 300;
    letter-spacing: 0.04em;
    color: var(--text-primary);
    text-shadow: none;
    margin: 1.25rem 0 0.1rem;
}

.twin-stage-name {
    font-family: var(--font-body, 'Inter', sans-serif);
    font-size: 0.75rem;
    font-style: normal;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--text-muted);
}

/* Avatar core: use accent-gold tint instead of teal glow */
.avatar-core {
    background: radial-gradient(circle at 30% 30%,
        rgba(196, 167, 125, 0.35) 0%,
        rgba(139, 115, 85, 0.18) 70%,
        rgba(0, 0, 0, 0) 100%);
    border: 1.5px solid rgba(196, 167, 125, 0.5);
    box-shadow:
        inset 0 0 20px rgba(196, 167, 125, 0.15),
        0 0 40px rgba(196, 167, 125, 0.12);
}

.ring { border-color: rgba(196, 167, 125, 0.14); }

/* TEI section: tighter, unified with avatar section above */
.tei-section {
    padding: 0 1rem 2rem;
}

.tei-display {
    max-width: 520px;
    margin: 0 auto;
}

.tei-score-container { width: 200px; height: 200px; }

.tei-bg  { stroke: rgba(255, 255, 255, 0.05); stroke-width: 10; }
.tei-fill { stroke: var(--accent, #C4A77D); stroke-width: 10; filter: drop-shadow(0 0 8px rgba(196, 167, 125, 0.35)); }

.tei-number {
    font-family: var(--font-display, 'Crimson Pro', serif);
    color: var(--accent, #C4A77D);
    font-weight: 300;
    letter-spacing: 0.02em;
}

.tei-label {
    font-size: 0.65rem;
    letter-spacing: 0.16em;
    margin-top: 4px;
}

/* ── Section titles: serif, warmer ── */

.section-title {
    font-family: var(--font-display, 'Crimson Pro', serif);
    font-size: 1.4rem;
    font-weight: 400;
    letter-spacing: 0.01em;
    color: var(--text-primary);
    margin: 0 0 1.25rem;
}

.section-title .title-icon {
    color: var(--accent, #C4A77D);
}

.card-title {
    font-family: var(--font-display, 'Crimson Pro', serif);
    font-weight: 400;
    letter-spacing: 0.01em;
    color: var(--text-primary);
}

/* Overall page: add breathing space between sections */
.twin-container > section {
    padding: 2rem 0;
    border-top: 1px solid var(--border-subtle, rgba(255,255,255,0.04));
}
.twin-container > section:first-child,
.twin-container > section.twin-avatar-section,
.twin-container > section.tei-section {
    border-top: none;
    padding-top: 0.5rem;
}

/* ── Journey: horizontal timeline with per-marker rail segments ──
   Each marker paints the rail to its NEXT sibling via ::after. This
   is robust to any spacing and never drifts from the dot centers,
   which was the bug in the container-level ::before approach. */

.stages-timeline {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 0;
    padding: 2rem 0 0.5rem;
    overflow: visible;
}

.stage-marker {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    background: none;
    border: none;
    padding: 0;
}

/* Rail segment connects this dot's right edge to the next dot's left edge.
   Positioned at the dot's vertical center (48px / 2 = 24px + 0 padding-top
   on marker, which sits inside the container's 2rem padding-top). */
.stage-marker::after {
    content: '';
    position: absolute;
    top: 23px;
    left: calc(50% + 24px);
    right: calc(-50% + 24px);
    height: 2px;
    background: var(--border-color, #3a3a42);
    border-radius: 1px;
    z-index: 0;
}
.stage-marker:last-child::after { display: none; }
.stage-marker.completed::after { background: var(--accent, #C4A77D); }
.stage-marker.current::after {
    background: linear-gradient(to right,
        var(--accent, #C4A77D) 0%,
        var(--accent, #C4A77D) 50%,
        var(--border-color, #3a3a42) 50%,
        var(--border-color, #3a3a42) 100%
    );
}

.stage-marker .stage-dot {
    width: 48px;
    height: 48px;
    position: relative;
    z-index: 1;
}

.stage-info {
    display: flex;
    flex-direction: column;
    margin-top: 0.6rem;
    gap: 2px;
}
.stage-num {
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.stage-name {
    font-family: var(--font-display, 'Crimson Pro', serif);
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.25;
    max-width: 11ch;
}
.stage-marker.current .stage-name {
    color: var(--text-primary);
    font-weight: 500;
}
.stage-threshold {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
    font-variant-numeric: tabular-nums;
}

/* Narrow screens: let the timeline scroll horizontally */
@media (max-width: 800px) {
    .stages-timeline {
        overflow-x: auto;
        padding: 1.5rem 0.5rem;
        gap: 0.25rem;
        scroll-snap-type: x proximity;
    }
    .stage-marker { min-width: 90px; scroll-snap-align: start; }
}

/* ── Two-column dashboard layout for secondary sections ── */

@media (min-width: 1100px) {
    .recommendations-section,
    .enhanced-stats-section {
        display: inline-block;
        vertical-align: top;
        width: calc(50% - 0.75rem);
    }
    .recommendations-section { margin-right: 1.25rem; }

    /* Same for history + sync */
    .history-section,
    .sync-section {
        display: inline-block;
        vertical-align: top;
        width: calc(50% - 0.75rem);
    }
    .history-section { margin-right: 1.25rem; }
}

/* Unify card aesthetics across recommendations + stats */
.recommendations-section .card,
.enhanced-stats-section .card,
.stage-details-section .card {
    background: var(--bg-card, #12121a);
    border: 1px solid var(--border-color, #3a3a42);
    border-radius: 14px;
    padding: 1.5rem;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.02) inset;
}
.enhanced-stats-section .card { margin-bottom: 1rem; }

/* ── Evolution History: quieter, more scannable ── */

.history-timeline {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 520px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.history-event {
    display: grid;
    grid-template-columns: 36px 1fr auto;
    gap: 0.85rem;
    align-items: start;
    padding: 0.8rem 0.9rem;
    background: var(--bg-card, #12121a);
    border: 1px solid var(--border-color, #3a3a42);
    border-radius: 10px;
    transition: border-color 0.15s;
}
.history-event:hover { border-color: var(--accent, #C4A77D); }

.event-title {
    font-size: 0.9rem;
    color: var(--text-primary);
    line-height: 1.45;
}

.event-date {
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    white-space: nowrap;
    padding-top: 3px;
}

.event-change {
    margin-top: 0.35rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.companion-badge.subtle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: var(--bg-elevated, rgba(255,255,255,0.04));
    border-radius: 999px;
    color: var(--text-secondary);
    font-size: 0.7rem;
}

/* Custom scrollbar for history */
.history-timeline::-webkit-scrollbar { width: 6px; }
.history-timeline::-webkit-scrollbar-thumb {
    background: var(--border-color, #3a3a42);
    border-radius: 3px;
}
.history-timeline::-webkit-scrollbar-thumb:hover {
    background: var(--accent, #C4A77D);
}

/* ── Companion Sync: tighter cards with a subtle gold accent ── */

#syncGrid { gap: 0.85rem; }

.sync-companion {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 0.75rem;
    background: var(--bg-card, #12121a);
    border: 1px solid var(--border-color, #3a3a42);
    border-radius: 12px;
    transition: border-color 0.15s, transform 0.15s;
    text-align: center;
}
.sync-companion:hover { border-color: var(--accent, #C4A77D); transform: translateY(-2px); }
.sync-companion .companion-emoji {
    width: 40px; height: 40px;
    display: inline-flex; align-items: center; justify-content: center;
}
.sync-companion .companion-emoji svg { width: 26px; height: 26px; stroke-width: 1.75; }
.sync-companion .companion-name {
    font-family: var(--font-display, 'Crimson Pro', serif);
    font-size: 0.9rem;
    color: var(--text-primary);
}
.sync-companion .sync-bar {
    width: 100%; height: 4px;
    background: var(--border-subtle, rgba(255,255,255,0.06));
    border-radius: 2px; overflow: hidden;
}
.sync-companion .sync-fill {
    height: 100%;
    background: var(--accent, #C4A77D);
    transition: width 1.2s cubic-bezier(.25,.1,.25,1);
}
.sync-companion .sync-value {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}
.sync-companion .sync-interactions {
    font-size: 0.65rem;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

/* ── Stage details card: richer, less generic ── */

.stage-details-card h3 { font-size: 1.25rem; }
.stage-details-card .stage-description {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
}
.stage-details-card h4 {
    font-family: var(--font-body, 'Inter', sans-serif);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    margin: 1.25rem 0 0.6rem;
}
.capabilities-list {
    list-style: none;
    margin: 0; padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.5rem;
}
.capabilities-list li {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    padding: 0.4rem 0.6rem;
    background: var(--bg-elevated, rgba(255,255,255,0.03));
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--text-primary);
}
.cap-check {
    color: var(--accent, #C4A77D);
    font-size: 0.75rem;
}

.unlock-progress {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0.5rem 0 1rem;
}
.unlock-bar {
    flex: 1;
    height: 8px;
    background: var(--border-subtle, rgba(255,255,255,0.06));
    border-radius: 4px;
    overflow: hidden;
}
.unlock-fill {
    height: 100%;
    background: linear-gradient(90deg,
        var(--accent, #C4A77D),
        var(--accent-gold, #D4B896));
    transition: width 1.2s cubic-bezier(.25,.1,.25,1);
}
.unlock-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* ── Growth metrics: cleaner with tabular numbers + % ── */

.metric-row {
    display: grid;
    grid-template-columns: 110px 1fr auto;
    gap: 0.75rem;
    align-items: center;
    padding: 0.5rem 0;
}
.metric-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.metric-bar {
    height: 6px;
    background: var(--border-subtle, rgba(255,255,255,0.06));
    border-radius: 3px;
    overflow: hidden;
}
.metric-fill {
    height: 100%;
    background: var(--accent, #C4A77D);
    transition: width 1.2s cubic-bezier(.25,.1,.25,1);
}
.metric-fill.growth { background: var(--air, #87A889); }
.metric-fill.resilience { background: var(--ether, #9B8AA8); }

/* ── Pattern Insights: simpler list ── */

#patternInsights {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.insight-item {
    display: flex;
    gap: 0.6rem;
    padding: 0.6rem 0.75rem;
    background: var(--bg-elevated, rgba(255,255,255,0.03));
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}
.insight-icon {
    color: var(--accent, #C4A77D);
    flex-shrink: 0;
    margin-top: 1px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   STORY SECTION — a scannable synthesized narrative
   ═══════════════════════════════════════════════════════════════════════════ */

.story-section {
    padding: 0 !important;
    border-top: none !important;
}

.story-card {
    background:
        radial-gradient(ellipse at top left, rgba(196, 167, 125, 0.06), transparent 60%),
        var(--bg-card, #12121a);
    border: 1px solid var(--border-color, #3a3a42);
    border-radius: 16px;
    padding: 1.75rem 2rem;
    position: relative;
    overflow: hidden;
}
.story-card::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: linear-gradient(
        to bottom,
        var(--accent, #C4A77D) 0%,
        rgba(196, 167, 125, 0.2) 100%
    );
}

.story-text {
    font-family: var(--font-display, 'Crimson Pro', serif);
    font-size: clamp(1.05rem, 1.5vw, 1.3rem);
    font-weight: 300;
    line-height: 1.65;
    color: var(--text-primary);
    margin: 0 0 1.5rem;
    letter-spacing: 0.005em;
}
.story-text strong {
    font-weight: 500;
    color: var(--accent, #C4A77D);
}

.story-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
}

.story-stat {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 0.25rem 0;
}
.story-stat-value {
    font-family: var(--font-display, 'Crimson Pro', serif);
    font-size: 1.5rem;
    font-weight: 300;
    color: var(--accent, #C4A77D);
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}
.story-stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    margin-top: 2px;
}

@media (max-width: 600px) {
    .story-card { padding: 1.25rem 1.25rem 1.25rem 1.35rem; }
    .story-stats { grid-template-columns: repeat(3, 1fr); gap: 0.25rem; }
    .story-stat-value { font-size: 1.25rem; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   TOP GRID — avatar+TEI + story + vectors as a dashboard
   ═══════════════════════════════════════════════════════════════════════════ */

.top-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.top-grid > section {
    /* Reset the universal section border we added earlier;
       inside the grid each section owns its own styling. */
    padding: 0 !important;
    border-top: none !important;
}

/* Wide screens: 2x2 grid — left column has avatar on top, TEI below;
   right column has story on top, vectors below. */
@media (min-width: 1000px) {
    .top-grid {
        grid-template-columns: minmax(320px, 0.9fr) minmax(0, 1.4fr);
        grid-template-areas:
            "avatar  story"
            "tei     vectors";
        column-gap: 1.5rem;
        row-gap: 1.25rem;
        align-items: stretch;
    }
    .top-grid > .twin-avatar-section { grid-area: avatar; }
    .top-grid > .tei-section         { grid-area: tei; }
    .top-grid > .story-section       { grid-area: story; }
    .top-grid > .vectors-section     { grid-area: vectors; }

    /* Both left-column cells share the same warm-gold card aesthetic */
    .top-grid > .twin-avatar-section,
    .top-grid > .tei-section {
        background: linear-gradient(
            180deg,
            rgba(196, 167, 125, 0.05) 0%,
            rgba(196, 167, 125, 0.015) 60%,
            transparent 100%);
        border: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
        border-radius: 16px;
        padding: 1.5rem !important;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-direction: column;
    }

    /* Vectors render as 2-col inside the right column */
    .top-grid > .vectors-section .vectors-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Story card fills its grid cell */
    .top-grid > .story-section .story-card {
        height: 100%;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   INSIGHTS GRID — 5 cards laid out as a dashboard grid
   ═══════════════════════════════════════════════════════════════════════════ */

.insights-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 2rem 0 !important;
    border-top: 1px solid var(--border-subtle, rgba(255,255,255,0.04));
}

.insights-card {
    background: var(--bg-card, #12121a);
    border: 1px solid var(--border-color, #3a3a42);
    border-radius: 14px;
    padding: 1.5rem;
    transition: border-color 0.2s, transform 0.2s;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 0;
}
.insights-card:hover { border-color: rgba(196, 167, 125, 0.3); }

.insights-card .card-title {
    margin: 0;
    font-size: 1.1rem;
    font-family: var(--font-display, 'Crimson Pro', serif);
    font-weight: 400;
    letter-spacing: 0.01em;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.insights-card .card-title .title-icon { color: var(--accent, #C4A77D); }

/* Tablet: 2 cols */
@media (min-width: 720px) {
    .insights-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Desktop: 3 cols with the sync card spanning full width */
@media (min-width: 1200px) {
    .insights-grid {
        grid-template-columns: repeat(3, 1fr);
        grid-auto-rows: minmax(280px, auto);
    }
    .card-recommendations { grid-column: span 2; grid-row: span 1; }
    .card-metrics         { grid-column: span 1; }
    .card-state           { grid-column: span 1; }
    .card-patterns        { grid-column: span 2; }
    .card-sync            { grid-column: 1 / -1; }
}

/* Ultra-wide: 4 cols — fit everything in two rows */
@media (min-width: 1600px) {
    .insights-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    .card-recommendations { grid-column: span 2; }
    .card-metrics         { grid-column: span 1; }
    .card-state           { grid-column: span 1; }
    .card-patterns        { grid-column: span 2; }
    .card-sync            { grid-column: span 2; }
}

/* Style resets / adjustments for moved cards */
.card-recommendations .companion-recs-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}
@media (min-width: 1200px) {
    .card-recommendations .companion-recs-grid {
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    }
}

.card-sync .sync-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 0.75rem;
}

/* Emotional state indicator compact */
#emotionalStateIndicator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.state-badge {
    width: 40px; height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
}
.state-label {
    font-family: var(--font-display, 'Crimson Pro', serif);
    font-size: 1.1rem;
    color: var(--text-primary);
}
.guidance-item {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border-subtle, rgba(255,255,255,0.04));
    font-size: 0.85rem;
}
.guidance-item:last-child { border-bottom: none; }
.guidance-label { color: var(--text-muted); }
.guidance-value { color: var(--text-primary); font-weight: 500; }

/* ═══════════════════════════════════════════════════════════════════════════
   JOURNEY FINAL POLISH — stretch markers + professional progress bar
   ═══════════════════════════════════════════════════════════════════════════ */

/* Make every marker the same vertical height so the row reads as one band */
.stages-timeline { align-items: stretch; }

.stage-marker {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

.stage-marker .stage-info {
    min-height: 2.4rem;         /* reserves space for 2-line names like "Co-Regulating Presence" */
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
}

.stage-marker .stage-threshold {
    margin-top: auto;           /* pin threshold to the bottom */
    padding-top: 0.4rem;
    min-height: 1.1rem;
}

/* Unified visual height for all markers — locked markers without a
   threshold still reserve its space so rows align */
.stage-marker.locked::after-placeholder,
.stage-marker.locked:not(:has(.stage-threshold)) {
    /* cross-browser min-height guarantee */
}
.stage-marker.locked {
    padding-bottom: 1.5rem;
}

/* ── Progress bar (unlock to next stage) — professional look ── */

.unlock-progress {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin: 0.5rem 0 1rem;
}

.unlock-progress-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.unlock-progress-head strong {
    color: var(--accent, #C4A77D);
    font-family: var(--font-display, 'Crimson Pro', serif);
    font-size: 0.95rem;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0.01em;
}

.unlock-bar {
    position: relative;
    height: 10px;
    background: linear-gradient(180deg,
        rgba(0,0,0,0.35) 0%,
        rgba(0,0,0,0.15) 100%);
    border-radius: 999px;
    overflow: hidden;
    box-shadow:
        inset 0 1px 2px rgba(0, 0, 0, 0.45),
        inset 0 0 0 1px var(--border-subtle, rgba(255,255,255,0.05));
}

.unlock-fill {
    height: 100%;
    position: relative;
    background: linear-gradient(90deg,
        var(--accent, #C4A77D) 0%,
        var(--accent-gold, #D4B896) 100%);
    border-radius: 999px;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.25),
        0 0 12px rgba(196, 167, 125, 0.35);
    transition: width 1.2s cubic-bezier(.25,.1,.25,1);
}
.unlock-fill::after {
    /* Subtle moving shimmer to give the bar energy */
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.22) 50%,
        transparent 100%);
    transform: translateX(-100%);
    animation: unlock-shimmer 2.6s ease-in-out infinite;
}
@keyframes unlock-shimmer {
    0%   { transform: translateX(-100%); }
    60%  { transform: translateX(200%); }
    100% { transform: translateX(200%); }
}

/* Numeric markers beneath the bar (from / now / to) */
.unlock-scale {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}
.unlock-scale .now {
    color: var(--accent, #C4A77D);
    font-weight: 600;
}

.unlock-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) {
    .unlock-fill::after { animation: none; display: none; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   FIX: TEI card overlapping the stage-name above it
   The TEI ring (200px) was visually crowding the "Insight Companion"
   label because the avatar section ended tight against the TEI section.
   Give the two left-column cards generous internal padding and a wider
   row gap so they read as clearly separate cards.
   ═══════════════════════════════════════════════════════════════════════════ */

@media (min-width: 1000px) {
    .top-grid {
        row-gap: 2rem;            /* was 1.25rem */
    }

    .top-grid > .twin-avatar-section {
        padding: 2rem 1.5rem 2rem !important;
        gap: 0.5rem;
        min-height: 320px;
        overflow: hidden;         /* keep rings + glow inside */
        contain: layout paint;
    }

    .top-grid > .tei-section {
        padding: 2rem 1.5rem 1.5rem !important;
        gap: 1rem;
        overflow: hidden;
        contain: layout paint;
    }

    /* Give the stage name a bit more room below the avatar */
    .top-grid > .twin-avatar-section .twin-stage-title {
        margin-top: 1.5rem;
    }
    .top-grid > .twin-avatar-section .twin-stage-name {
        margin-bottom: 0.5rem;
    }

    /* TEI ring inside its cell: don't let it hog all vertical space */
    .top-grid > .tei-section .tei-score-container {
        width: 180px;
        height: 180px;
    }
}
