.lifecycle-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: var(--space-6);
    align-items: start;
}

.stage-rail {
    background: white;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: sticky;
    top: 84px;
    max-height: calc(100vh - 110px);
    overflow-y: auto;
}

.stage-rail-head {
    padding: var(--space-4);
    border-bottom: 1px solid var(--border-light);
    background: var(--gray-50);
}

.stage-item {
    display: grid;
    grid-template-columns: 34px 1fr auto;
    gap: var(--space-3);
    align-items: center;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    border-right: 3px solid transparent;
    transition: all 0.15s;
}

.stage-item:hover {
    background: var(--gray-50);
}

.stage-item.active {
    background: rgba(15, 76, 58, 0.07);
    border-right-color: var(--color-primary);
}

.stage-num {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--gray-200);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
}

.stage-item.done .stage-num {
    background: var(--color-success);
    color: white;
}

.stage-item.current .stage-num {
    background: var(--color-primary);
    color: white;
    box-shadow: 0 0 0 4px rgba(15, 76, 58, 0.12);
}

.stage-name {
    font-weight: 700;
    font-size: 12px;
    color: var(--text-primary);
}

.stage-desc {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 2px;
}

.stage-section {
    background: white;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-6);
    overflow: hidden;
}

.stage-section-head {
    padding: var(--space-5) var(--space-6);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-4);
    background: linear-gradient(180deg, #ffffff, var(--gray-50));
}

.stage-section-title {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: 16px;
    font-weight: 800;
}

.stage-section-body {
    padding: var(--space-6);
}

.atomic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-4);
}

.atomic-card {
    padding: var(--space-4);
    background: var(--gray-50);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
}

.atomic-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.atomic-value {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 13px;
}

.word-token-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: var(--space-4);
    background: var(--gray-50);
    border-radius: var(--radius-md);
}

.word-token {
    font-family: var(--font-hadith);
    font-size: 18px;
    background: white;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 4px 10px;
    cursor: pointer;
}

.word-token.semantic {
    border-bottom: 3px solid var(--color-accent);
}
.word-token.morph {
    border-bottom: 3px solid var(--color-success);
}
.word-token.syntax {
    border-bottom: 3px solid var(--color-info);
}
.word-token.rhetoric {
    border-bottom: 3px solid #8b5cf6;
}
.word-token:hover {
    background: rgba(15, 76, 58, 0.06);
}

.analysis-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-4);
    margin-bottom: var(--space-5);
}

.analysis-summary-card {
    background: white;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    text-align: center;
}

.analysis-summary-card .icon {
    font-size: 26px;
    margin-bottom: 6px;
}

.analysis-summary-card .num {
    font-size: 22px;
    font-weight: 800;
    font-family: var(--font-mono);
    color: var(--color-primary);
}

.analysis-summary-card .lbl {
    font-size: 11px;
    color: var(--text-muted);
}

.relation-map {
    background: linear-gradient(180deg, #f8fafc, #fff);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    min-height: 280px;
}

.approval-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-4);
}

.approval-card {
    padding: var(--space-4);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    background: var(--gray-50);
}

.approval-card.done {
    border-color: var(--color-success);
    background: #f0fdf4;
}

.approval-card.warning {
    border-color: var(--color-warning);
    background: #fffbeb;
}

.mini-timeline {
    position: relative;
    padding-right: 28px;
}

.mini-timeline::before {
    content: "";
    position: absolute;
    right: 10px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-light);
}

.mini-event {
    position: relative;
    padding: 0 0 var(--space-4);
}

.mini-event::before {
    content: "";
    position: absolute;
    right: -24px;
    top: 4px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--color-primary);
    border: 3px solid white;
    box-shadow: 0 0 0 1px var(--border-light);
}

.mini-event-title {
    font-weight: 700;
    font-size: 13px;
}

.mini-event-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.sticky-actions {
    position: sticky;
    bottom: 16px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-xl);
    padding: 8px 12px;
    display: flex;
    gap: var(--space-2);
    justify-content: center;
    backdrop-filter: blur(10px);
    z-index: 5;
}

html.mockup-dark .stage-rail,
html.mockup-dark .stage-section,
html.mockup-dark .analysis-summary-card,
html.mockup-dark .atomic-card,
html.mockup-dark .word-token,
html.mockup-dark .approval-card {
    background: var(--bg-card) !important;
}

html.mockup-dark .stage-section-head {
    background: linear-gradient(180deg, var(--bg-card), var(--gray-50));
}

html.mockup-dark .approval-card.done {
    background: rgba(16, 185, 129, 0.12) !important;
}

html.mockup-dark .approval-card.warning {
    background: rgba(245, 158, 11, 0.12) !important;
}

/* =========================================================
   توسعات تفاعلية إضافية
   ========================================================= */

.stage-item.upcoming .stage-num {
    background: var(--gray-100);
    color: var(--text-muted);
}

.progress-banner {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-5);
    background: linear-gradient(135deg, #f5f0e3, #ffffff);
    border: 1px solid var(--color-accent-light);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-5);
}

.progress-banner .ring {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: conic-gradient(
        var(--color-primary) 0 calc(var(--p, 0) * 1%),
        var(--gray-200) calc(var(--p, 0) * 1%) 100%
    );
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
}

.progress-banner .ring::after {
    content: "";
    position: absolute;
    inset: 6px;
    background: white;
    border-radius: 50%;
}

.progress-banner .ring .v {
    position: relative;
    z-index: 1;
    font-family: var(--font-mono);
    font-size: 16px;
    font-weight: 800;
    color: var(--color-primary);
}

.progress-banner .info {
    flex: 1;
}

.progress-banner .info h4 {
    font-size: 14px;
    font-weight: 800;
    margin-bottom: 4px;
}

.progress-banner .info p {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.7;
}

.kbd-hint {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--text-muted);
    margin-right: auto;
}

.kbd-hint kbd {
    font-family: var(--font-mono);
    background: var(--gray-100);
    border: 1px solid var(--border-medium);
    border-bottom-width: 2px;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 10px;
    color: var(--text-secondary);
}

/* تعليقات Hover للكلمات في المتن */
.word-token {
    position: relative;
    transition:
        transform 0.15s,
        background 0.15s;
}
.word-token:hover {
    transform: translateY(-2px);
}
.word-token.is-pinned {
    background: rgba(15, 76, 58, 0.1);
    outline: 2px solid var(--color-primary);
    outline-offset: 1px;
}

/* لتمييز صف الجدول المحدد */
.row-highlight {
    background: rgba(201, 169, 97, 0.18) !important;
    outline: 2px solid var(--color-accent);
    outline-offset: -2px;
}

/* شريط تقدم رأسي في جانب الصفحة */
.vertical-progress {
    position: fixed;
    top: 120px;
    bottom: 80px;
    right: 8px;
    width: 6px;
    background: var(--gray-200);
    border-radius: 99px;
    z-index: 100;
    overflow: hidden;
}
.vertical-progress::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    height: var(--scroll, 0%);
    background: linear-gradient(
        180deg,
        var(--color-primary),
        var(--color-accent)
    );
    transition: height 0.1s linear;
}

/* سلاسل الأقسام الرئيسية (Section anchors) */
.stage-section[data-active="true"] {
    box-shadow: 0 0 0 3px rgba(15, 76, 58, 0.12);
}

/* جدول ملخص التحليلات */
.analysis-overview {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-3);
    margin-top: var(--space-4);
}

.analysis-overview .ov {
    padding: var(--space-3) var(--space-4);
    background: var(--gray-50);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    font-size: 12px;
}

.analysis-overview .ov strong {
    font-size: 13px;
}
.analysis-overview .ov .pct {
    font-family: var(--font-mono);
    color: var(--color-primary);
    font-weight: 800;
    font-size: 14px;
}

/* شريط إجراءات رأسي */
.right-actions {
    position: fixed;
    top: 50%;
    right: 22px;
    transform: translateY(-50%);
    z-index: 90;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: white;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-full);
    padding: 6px;
    box-shadow: var(--shadow-md);
}

.right-actions button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--gray-100);
    font-size: 14px;
    color: var(--text-primary);
}

.right-actions button:hover {
    background: var(--color-primary);
    color: white;
}
