:root {
    /* Aligned with PublicHome palette: indigo→violet primary, light neutral surfaces. */
    --sand-50:  #ffffff;
    --sand-100: #f8f9fa;
    --sand-200: #eef0f4;
    --sand-300: #cbd5e0;
    --sand-400: #a0aec0;
    --terra-500: #667eea;
    --terra-600: #764ba2;
    --ink-900: #1a202c;
    --ink-700: #2c3e50;
    --ink-500: #4a5568;
    --ink-300: #a0aec0;
    --line:    rgba(26, 32, 44, 0.08);
    --line-2:  rgba(26, 32, 44, 0.14);
    --glass:   rgba(255, 255, 255, 0.78);
    --glass-strong: rgba(255, 255, 255, 0.96);
    --accent:  #667eea;
    --accent-ink: #764ba2;
    --shadow-card: 0 30px 60px -28px rgba(38, 35, 88, 0.32), 0 8px 22px -12px rgba(38, 35, 88, 0.16);
    --shadow-pill: 0 16px 32px -18px rgba(38, 35, 88, 0.30), 0 2px 6px rgba(38, 35, 88, 0.08);
}

*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'IBM Plex Sans Arabic', 'Inter', system-ui, sans-serif;
    color: var(--ink-900);
    background: #f8f9fa;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* Brand mark — small villa silhouette reused on hub + detail topbars. */
.hub-brand-mark, .element-brand-mark {
    width: 40px; height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    position: relative;
    box-shadow: var(--shadow-pill);
    flex-shrink: 0;
}
.hub-brand-mark::before, .hub-brand-mark::after,
.element-brand-mark::before, .element-brand-mark::after {
    content: ''; position: absolute; background: var(--sand-50);
}
.hub-brand-mark::before, .element-brand-mark::before {
    left: 6px; right: 6px; top: 9px; height: 12px;
    clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
.hub-brand-mark::after, .element-brand-mark::after {
    left: 8px; right: 8px; bottom: 9px; height: 16px;
    border-radius: 1px 1px 0 0;
}

/* ═══════════════════════════════════════════════════════════════════
   HUB PAGE — /elements
   ═══════════════════════════════════════════════════════════════════ */
.elements-hub {
    min-height: 100vh;
    background:
        radial-gradient(1200px 600px at 20% -10%, rgba(102, 126, 234, 0.12), transparent 60%),
        radial-gradient(900px 500px at 100% 110%, rgba(118, 75, 162, 0.10), transparent 60%),
        #f8f9fa;
    padding: 28px 28px 80px;
}

.hub-topbar {
    max-width: 1320px;
    margin: 0 auto 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.hub-brand {
    display: flex; align-items: center; gap: 14px;
}
.hub-brand-text {
    line-height: 1.2;
}
.hub-brand-title {
    font-weight: 700;
    font-size: 18px;
    color: var(--ink-900);
}
.hub-brand-sub {
    font-size: 12px;
    color: var(--ink-500);
    font-family: 'Inter', sans-serif;
    direction: ltr;
}
.hub-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--glass-strong);
    border: 1px solid var(--line-2);
    border-radius: 999px;
    color: var(--ink-700);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-pill);
    transition: transform .15s ease, background .15s ease;
}
.hub-back:hover { background: #fff; transform: translateY(-1px); color: var(--accent-ink); }
.hub-back svg { width: 16px; height: 16px; }

.hub-intro {
    max-width: 1100px;
    margin: 0 auto 32px;
    text-align: center;
}
.hub-title {
    font-size: clamp(28px, 4vw, 44px);
    font-weight: 700;
    margin: 0 0 12px;
    color: var(--ink-900);
    letter-spacing: -0.01em;
}
.hub-lede {
    font-size: 16px;
    line-height: 1.8;
    color: var(--ink-700);
    max-width: 760px;
    margin: 0 auto;
}

.hub-grid {
    max-width: 1320px;
    margin: 0 auto;
}
.hub-group-header {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--accent-ink);
    margin: 24px 0 14px;
    text-transform: none;
}
.hub-group-dot {
    width: 8px; height: 8px;
    background: var(--accent);
    border-radius: 2px;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.18);
}
.hub-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}
.hub-card {
    position: relative;
    display: flex;
    align-items: stretch;
    gap: 14px;
    padding: 18px 18px 18px 14px;
    background: var(--glass-strong);
    border: 1px solid var(--line-2);
    border-radius: 16px;
    color: inherit;
    text-decoration: none;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
    box-shadow: 0 4px 14px -6px rgba(38, 35, 88, 0.10);
    overflow: hidden;
}
.hub-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-card);
    border-color: var(--accent);
    color: inherit;
    text-decoration: none;
}
.hub-card-num {
    flex: 0 0 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(140deg, rgba(102, 126, 234, 0.18), rgba(102, 126, 234, 0.08));
    color: var(--accent-ink);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    font-size: 15px;
    direction: ltr;
    font-feature-settings: "tnum" 1;
}
.hub-card-body {
    flex: 1;
    min-width: 0;
}
.hub-card-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--ink-900);
    margin: 0 0 6px;
    line-height: 1.35;
}
.hub-card-desc {
    font-size: 13.5px;
    line-height: 1.65;
    color: var(--ink-700);
    margin: 0 0 10px;
}
.hub-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.hub-tag {
    font-size: 11px;
    padding: 3px 8px;
    background: rgba(26, 32, 44, 0.05);
    border: 1px solid var(--line);
    color: var(--ink-500);
    border-radius: 999px;
    font-weight: 500;
}
.hub-card-arrow {
    align-self: center;
    color: var(--accent);
    opacity: 0.55;
    transition: opacity .15s, transform .15s;
}
.hub-card-arrow svg { width: 18px; height: 18px; }
.hub-card:hover .hub-card-arrow { opacity: 1; transform: translateX(-3px); }

.hub-card.soon {
    opacity: 0.85;
}
.hub-card-soon {
    position: absolute;
    top: 12px;
    inset-inline-end: 12px;
    font-size: 10.5px;
    padding: 2px 8px;
    background: rgba(102, 126, 234, 0.18);
    color: var(--accent-ink);
    border-radius: 999px;
    font-weight: 600;
}

.hub-footer {
    max-width: 1320px;
    margin: 56px auto 0;
    text-align: center;
}
.hub-footer-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 22px;
    background: var(--ink-900);
    color: var(--sand-50);
    border-radius: 999px;
    text-decoration: none;
    font-weight: 600;
    transition: background .15s ease, transform .15s ease;
}
.hub-footer-link:hover {
    background: var(--accent-ink);
    color: #fff;
    text-decoration: none;
    transform: translateY(-2px);
}
.hub-footer-link svg { width: 16px; height: 16px; }

/* ═══════════════════════════════════════════════════════════════════
   DETAIL PAGE — /elements/{slug}
   ═══════════════════════════════════════════════════════════════════ */
.element-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: #f8f9fa;
}

.element-topbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 22px;
    background: var(--glass-strong);
    border-bottom: 1px solid var(--line-2);
    box-shadow: 0 1px 8px rgba(38, 35, 88, 0.06);
    z-index: 5;
    position: sticky;
    top: 0;
}
.element-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13.5px;
    color: var(--ink-500);
    flex-wrap: wrap;
    min-width: 0;
}
.element-breadcrumb a {
    color: var(--ink-700);
    text-decoration: none;
    transition: color .15s;
}
.element-breadcrumb a:hover { color: var(--accent-ink); }
.element-breadcrumb .sep { opacity: 0.5; }
.element-breadcrumb .current {
    color: var(--ink-900);
    font-weight: 600;
}
.element-top-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}
.element-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: rgba(26, 32, 44, 0.04);
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--ink-700);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: background .15s, color .15s;
}
.element-pill:hover {
    background: rgba(102, 126, 234, 0.10);
    color: var(--accent-ink);
}
.element-pill svg { width: 14px; height: 14px; }

.element-main {
    /* Canvas spans the full screen width; height is capped so the step
       controls (overlay) and detail text below stay visible on both
       desktop and mobile. */
    flex: 0 0 auto;
    padding: 12px;
    direction: rtl;
}
.element-main > .element-stage {
    width: 100%;
    height: clamp(400px, 65vh, 720px);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--line-2);
}

/* Element prev/next overlay — pinned to top-center of the canvas. */
.element-nav-overlay {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 5;
    direction: rtl;
}
.element-nav-overlay .element-nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    background: var(--glass-strong);
    border: 1px solid var(--line-2);
    border-radius: 10px;
    color: var(--ink-700);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    transition: background .15s, color .15s, transform .15s;
    box-shadow: var(--shadow-pill);
}
.element-nav-overlay .element-nav-btn:hover {
    background: #fff;
    color: var(--accent-ink);
    transform: translateY(-1px);
    text-decoration: none;
}
.element-nav-overlay .element-nav-btn svg {
    width: 14px; height: 14px;
    flex-shrink: 0;
}
.element-nav-overlay .element-nav-btn.list {
    padding: 7px 9px;
}
.element-nav-overlay .element-nav-name {
    max-width: 160px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.element-stage {
    position: relative;
    --element-steps-safe-space: 104px;
    background:
        radial-gradient(800px 500px at 30% 30%, rgba(102,126,234,0.10), transparent 70%), linear-gradient(160deg, #f8f9fa 0%, #eef0f4 55%, #e2e8f0 100%);
    overflow: hidden;
    /* Fill the grid cell — defensive in case implicit-row sizing collapses. */
    align-self: stretch;
    height: 100%;
}
.element-main > .element-stage-plumbing {
    height: clamp(500px, 72vh, 760px);
}
.element-main > .element-stage-reinforcement-schedules {
    height: clamp(560px, 78vh, 840px);
}
#element-canvas {
    position: absolute;
    inset: 0 0 auto 0;
    width: 100%;
    height: calc(100% - var(--element-steps-safe-space));
    display: block;
    touch-action: none;
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28'%3E%3Cpath d='M16.5 25.5c-4.4 0-7.3-2.1-8.9-5.2l-2.3-4.4c-.5-1-.1-2.1.9-2.6.9-.4 1.9-.1 2.5.7l.9 1.3V6.2c0-1.1.9-2 2-2s2 .9 2 2v6.2-8.1c0-1.1.9-2 2-2s2 .9 2 2v8.1-6.6c0-1.1.9-2 2-2s2 .9 2 2v7.1-4.4c0-1.1.9-2 2-2s2 .9 2 2v8.7c0 5-3.4 8.3-9.1 8.3Z' fill='none' stroke='white' stroke-width='4.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M16.5 25.5c-4.4 0-7.3-2.1-8.9-5.2l-2.3-4.4c-.5-1-.1-2.1.9-2.6.9-.4 1.9-.1 2.5.7l.9 1.3V6.2c0-1.1.9-2 2-2s2 .9 2 2v6.2-8.1c0-1.1.9-2 2-2s2 .9 2 2v8.1-6.6c0-1.1.9-2 2-2s2 .9 2 2v7.1-4.4c0-1.1.9-2 2-2s2 .9 2 2v8.7c0 5-3.4 8.3-9.1 8.3Z' fill='%2394a3b8' stroke='%2364758b' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") 12 12, grab;
}
#element-canvas:active {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28'%3E%3Cpath d='M7.5 14.2V8.4c0-1 .8-1.8 1.8-1.8s1.8.8 1.8 1.8v5.2-7.8c0-1 .8-1.8 1.8-1.8s1.8.8 1.8 1.8v7.7-6.3c0-1 .8-1.8 1.8-1.8s1.8.8 1.8 1.8v6.5-4.1c0-1 .8-1.8 1.8-1.8s1.8.8 1.8 1.8v7.3c0 5.1-3.1 8.1-8.1 8.1-3.8 0-6.4-1.8-7.9-4.6l-1.7-3.1c-.5-1-.2-2.1.8-2.6.9-.5 1.9-.2 2.5.6Z' fill='none' stroke='white' stroke-width='4.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M7.5 14.2V8.4c0-1 .8-1.8 1.8-1.8s1.8.8 1.8 1.8v5.2-7.8c0-1 .8-1.8 1.8-1.8s1.8.8 1.8 1.8v7.7-6.3c0-1 .8-1.8 1.8-1.8s1.8.8 1.8 1.8v6.5-4.1c0-1 .8-1.8 1.8-1.8s1.8.8 1.8 1.8v7.3c0 5.1-3.1 8.1-8.1 8.1-3.8 0-6.4-1.8-7.9-4.6l-1.7-3.1c-.5-1-.2-2.1.8-2.6.9-.5 1.9-.2 2.5.6Z' fill='%238899aa' stroke='%2364758b' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") 12 12, grabbing;
}

.element-page.stage-full .element-side { display: none; }
.element-page.stage-full .element-main { grid-template-columns: 1fr; }

/* ── Per-scene step controls (overlay on the canvas) ────────── */
.element-steps {
    position: absolute;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--glass-strong);
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    border: 1px solid var(--line-2);
    border-radius: 14px;
    padding: 10px 14px 10px 14px;
    box-shadow: var(--shadow-card);
    display: flex;
    align-items: center;
    gap: 14px;
    z-index: 5;
    direction: rtl;
    min-width: 360px;
    max-width: calc(100% - 40px);
}
.el-steps-text {
    /* Fixed-width text area so different title lengths don't push the
       prev/next buttons around — pill width stays constant. */
    flex: 0 0 240px;
    width: 240px;
    text-align: center;
    min-width: 0;
}
.el-steps-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--ink-900);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* .el-steps-desc removed — pill shows only title + counter + buttons now. */
.el-steps-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.el-steps-controls button {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--ink-900);
    color: var(--sand-50);
    border: 0;
    cursor: pointer;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .15s ease, transform .15s ease;
    padding: 0;
}
.el-steps-controls button:hover:not(:disabled) {
    background: var(--accent-ink);
    transform: translateY(-1px);
}
.el-steps-controls button:disabled {
    opacity: 0.30;
    cursor: not-allowed;
}
.el-steps-controls button svg {
    width: 16px;
    height: 16px;
}
.el-steps-counter {
    display: inline-flex;
    flex-direction: row;
    gap: 4px;
    align-items: center;
    justify-content: center;
    font-family: 'Inter', sans-serif;
    font-feature-settings: "tnum" 1;
    font-variant-numeric: tabular-nums;
    font-size: 12.5px;
    color: var(--ink-500);
    direction: rtl;
    min-width: 38px;
    text-align: center;
}
@media (max-width: 600px) {
    .element-stage {
        --element-steps-safe-space: 88px;
    }
    .element-steps {
        min-width: auto;
        bottom: 12px;
        padding: 8px 10px;
        gap: 10px;
    }
    .el-steps-text { flex: 0 0 160px; width: 160px; }
    .el-steps-title { font-size: 13px; }
}

.element-splash {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    background: linear-gradient(160deg, #f8f9fa 0%, #eef0f4 55%, #e2e8f0 100%);
    transition: opacity .5s ease;
    z-index: 2;
}
.element-splash.hidden { opacity: 0; pointer-events: none; }
.element-splash .spinner {
    width: 42px; height: 42px;
    border-radius: 50%;
    border: 3px solid rgba(26, 32, 44, 0.15);
    border-top-color: var(--accent);
    animation: el-spin .9s linear infinite;
}
@keyframes el-spin { to { transform: rotate(360deg); } }
.element-splash .label {
    font-size: 14px;
    color: var(--ink-700);
    font-weight: 500;
}

.element-side {
    background: var(--sand-50);
    /* Panel sits on the right (RTL) — border + shadow on its inline-end
       (left edge in RTL) so the separator is between panel and canvas. */
    border-inline-end: 1px solid var(--line-2);
    display: flex;
    flex-direction: column;
    min-height: 0;
    /* Ensure the panel fills its grid cell vertically and doesn't collapse
       to content height if the grid implicit-row behaviour misbehaves. */
    align-self: stretch;
    height: 100%;
    box-shadow: -8px 0 20px -8px rgba(38, 35, 88, 0.12);
}

.element-side-head {
    padding: 20px 22px 14px;
    border-bottom: 1px solid var(--line);
}
.element-side-phase {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--accent-ink);
    letter-spacing: 0.02em;
    margin-bottom: 6px;
}
.element-side-phase::before {
    content: '';
    width: 8px; height: 8px;
    border-radius: 2px;
    background: var(--accent);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.18);
}
.element-side-title {
    font-size: 22px;
    font-weight: 700;
    margin: 4px 0 8px;
    color: var(--ink-900);
    line-height: 1.3;
}
.element-side-lede {
    margin: 0;
    font-size: 14px;
    color: var(--ink-700);
    line-height: 1.7;
}

.element-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.5);
    flex-shrink: 0;
}
.element-tab {
    flex: 1 1 auto;
    padding: 8px 12px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--ink-500);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, color .15s;
    white-space: nowrap;
}
.element-tab:hover {
    background: rgba(102, 126, 234, 0.08);
    color: var(--accent-ink);
}
.element-tab.active {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
}

.element-tab-panels {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 18px 22px 24px;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.tab-panel p {
    line-height: 1.85;
    color: var(--ink-700);
    font-size: 14.5px;
    margin: 0 0 12px;
}
.tab-panel h4 {
    font-size: 15px;
    font-weight: 700;
    color: var(--ink-900);
    margin: 18px 0 8px;
}
.tab-panel ul, .tab-panel ol {
    padding-inline-start: 22px;
    margin: 0 0 14px;
    line-height: 1.85;
    color: var(--ink-700);
    font-size: 14.5px;
}
.tab-panel li {
    margin-bottom: 4px;
}
.tab-panel strong {
    color: var(--ink-900);
}
.tab-panel .muted {
    color: var(--ink-500);
    font-style: italic;
}

/* Type switcher chips (used in the Types tab). */
.type-switcher {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
}
.type-chip {
    padding: 6px 14px;
    background: rgba(26, 32, 44, 0.05);
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--ink-700);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
}
.type-chip:hover {
    background: rgba(102, 126, 234, 0.10);
    color: var(--accent-ink);
}
.type-chip.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.type-card {
    display: none;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid var(--line);
    border-radius: 12px;
    margin-bottom: 10px;
}
.type-card.active {
    display: block;
}
.type-card h4 {
    margin-top: 0;
    color: var(--accent-ink);
}

/* Rebar table. */
.rebar-table {
    width: 100%;
    border-collapse: collapse;
    margin: 14px 0;
    font-size: 13.5px;
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(38, 35, 88, 0.05);
}
.rebar-table th, .rebar-table td {
    padding: 9px 12px;
    text-align: start;
    border-bottom: 1px solid var(--line);
}
.rebar-table th {
    background: rgba(102, 126, 234, 0.12);
    color: var(--accent-ink);
    font-weight: 600;
    font-size: 13px;
}
.rebar-table tbody tr:last-child td { border-bottom: none; }
.rebar-table tbody tr:hover { background: rgba(102, 126, 234, 0.04); }

/* Acceptance checklist. */
.checklist {
    list-style: none;
    padding: 0;
    margin: 8px 0;
}
.checklist li {
    display: flex;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px dashed rgba(26, 32, 44, 0.08);
    font-size: 14px;
    line-height: 1.65;
    color: var(--ink-700);
}
.checklist li:last-child { border-bottom: none; }
.checklist .check {
    flex: 0 0 22px;
    height: 22px;
    background: var(--accent);
    color: #fff;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
}

/* Bottom nav between elements. */
.element-nav {
    flex: 0 0 auto;
    display: flex;
    align-items: stretch;
    gap: 6px;
    padding: 12px 14px;
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.7);
}
.element-nav-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--ink-700);
    text-decoration: none;
    font-size: 13px;
    transition: background .15s, border-color .15s, color .15s, transform .15s;
}
.element-nav-btn:hover:not(.disabled) {
    background: rgba(102, 126, 234, 0.08);
    border-color: var(--accent);
    color: var(--accent-ink);
    text-decoration: none;
    transform: translateY(-1px);
}
.element-nav-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.element-nav-btn.list {
    flex: 0 0 44px;
    justify-content: center;
}
.element-nav-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.element-nav-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    min-width: 0;
}
.element-nav-label {
    font-size: 11px;
    color: var(--ink-500);
    font-weight: 500;
}
.element-nav-name {
    font-size: 13.5px;
    color: var(--ink-900);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}
.element-nav-btn.next .element-nav-text { text-align: end; }

/* ── Detailed explanation section below the canvas ─────────────── */
.element-details {
    flex: 1 0 auto;
    width: 100%;
    max-width: 880px;
    margin: 0 auto;
    padding: 8px 24px 64px;
    direction: rtl;
}
.element-details-head {
    margin-bottom: 20px;
}
.element-details-phase {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-ink);
    margin-bottom: 8px;
}
.element-details-phase::before {
    content: '';
    width: 8px; height: 8px;
    border-radius: 2px;
    background: var(--accent);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.18);
}
.element-details-title {
    font-size: clamp(22px, 3vw, 30px);
    font-weight: 700;
    color: var(--ink-900);
    line-height: 1.3;
    margin: 0 0 8px;
}
.element-details-lede {
    font-size: 15.5px;
    color: var(--ink-700);
    line-height: 1.8;
    margin: 0;
}
.element-step-block {
    margin-top: 28px;
    padding: 22px 24px;
    background: var(--sand-50);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 2px 10px -4px rgba(38, 35, 88, 0.10);
}
.element-step-block .step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px; height: 30px;
    background: var(--accent);
    color: #fff;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 10px;
    direction: ltr;
}
.element-step-block .step-heading {
    font-size: 20px;
    font-weight: 700;
    color: var(--ink-900);
    margin: 0 0 10px;
    line-height: 1.35;
}
.element-step-block p,
.element-step-block ul,
.element-step-block ol {
    font-size: 14.5px;
    line-height: 1.85;
    color: var(--ink-700);
    margin: 0 0 12px;
}
.element-step-block ul, .element-step-block ol {
    padding-inline-start: 22px;
}
.element-step-block li { margin-bottom: 4px; }
.element-step-block strong { color: var(--ink-900); }
.element-step-block h4 {
    font-size: 15px;
    font-weight: 700;
    color: var(--ink-900);
    margin: 14px 0 6px;
}

/* "Element not found" fallback. */
.element-missing {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    background: #f8f9fa;
}
.element-missing h1 {
    font-size: 32px;
    color: var(--ink-900);
    margin: 0 0 12px;
}
.element-missing p {
    color: var(--ink-700);
    margin-bottom: 24px;
    font-size: 16px;
}
.element-missing code {
    background: rgba(26, 32, 44, 0.08);
    padding: 2px 8px;
    border-radius: 6px;
    font-family: 'Inter', monospace;
    font-size: 14px;
}
.element-missing-back {
    padding: 12px 26px;
    background: var(--accent);
    color: #fff;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 600;
}
.element-missing-back:hover {
    background: var(--accent-ink);
    color: #fff;
    text-decoration: none;
}

/* Responsive: mobile stacks the canvas above the panel. */
@media (max-width: 900px) {
    .element-main { padding: 8px; }
    .element-main > .element-stage {
        height: clamp(360px, 62vh, 520px);
        border-radius: 12px;
    }
    .element-details { padding: 4px 16px 48px; }
    .element-nav-overlay .element-nav-name {
        max-width: 90px;
        font-size: 12px;
    }
    .hub-grid { padding: 0 4px; }
    .elements-hub { padding: 16px 16px 60px; }
}

@media (max-width: 600px) {
    .element-topbar { padding: 10px 14px; }
    .element-pill span { display: none; }
    .element-breadcrumb { font-size: 12px; }
    .element-side-title { font-size: 19px; }
    .element-tabs { padding: 8px 10px; gap: 3px; }
    .element-tab { padding: 6px 10px; font-size: 12px; }
    .element-tab-panels { padding: 14px 16px 20px; }
    .element-nav-name { max-width: 90px; font-size: 12.5px; }
    .hub-title { font-size: 26px; }
    .hub-cards { grid-template-columns: 1fr; }
}

/* Hide the floating WhatsApp from PublicLayout on the detail page so it
   doesn't overlap the side panel nav. */
.element-page ~ .whatsapp-stack,
.elements-hub ~ .whatsapp-stack { display: none !important; }
