/* ── HERO ──────────────────────────────────────────────────────────────────── */
.ui-hero {
    position: relative;
    min-height: 340px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-bottom: 2px solid var(--scarlet);
}

.ui-hero-bg {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(42,56,184,0.18) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 50%, rgba(200,16,46,0.12) 0%, transparent 60%),
        linear-gradient(180deg, #060810 0%, #0a0f1a 100%);
}

.ui-hero-bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(42,56,184,0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(42,56,184,0.04) 1px, transparent 1px);
    background-size: 40px 40px;
}

.ui-hero-content {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 3rem 2rem;
    animation: heroFadeIn 0.8s ease both;
}

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

.ui-hero-logo {
    width: 96px;
    height: 96px;
    object-fit: contain;
    filter: drop-shadow(0 0 24px rgba(207,181,59,0.3));
    margin-bottom: 1rem;
    animation: heroPulse 4s ease-in-out infinite;
}

@keyframes heroPulse {
    0%,100% { filter: drop-shadow(0 0 16px rgba(207,181,59,0.25)); }
    50%      { filter: drop-shadow(0 0 32px rgba(207,181,59,0.5)); }
}

.ui-hero h1 {
    font-size: 2.4rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #fff;
    margin-bottom: .4rem;
    text-shadow: 0 2px 20px rgba(0,0,0,0.8);
}

.ui-hero-sub {
    font-size: 1.05rem;
    color: var(--gold);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 2rem;
}

.ui-hero-links {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.ui-hero-link-btn {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .55rem 1.2rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-accent);
    background: rgba(255,255,255,0.05);
    color: var(--text);
    text-decoration: none;
    font-size: .85rem;
    font-weight: 500;
    transition: background .15s, border-color .15s, color .15s;
}

.ui-hero-link-btn:hover {
    background: rgba(207,181,59,0.12);
    border-color: var(--gold);
    color: var(--gold);
}

.ui-hero-link-btn svg {
    flex-shrink: 0;
    opacity: .8;
}

/* ── TABLE OF CONTENTS BAR ─────────────────────────────────────────────────── */
.ui-toc-bar {
    background: var(--bg-nav);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 62px; /* height of main-nav */
    z-index: 90;
    padding: 0 2rem;
}

.ui-toc-bar .ui-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    max-width: 960px;
    height: 44px;
    overflow: hidden;
}

.ui-toc {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: nowrap;
    white-space: nowrap;
}

.ui-toc-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: .82rem;
    font-weight: 500;
    letter-spacing: .03em;
    padding: .25rem .1rem;
    border-bottom: 2px solid transparent;
    transition: color .15s, border-color .15s;
}

.ui-toc-link:hover {
    color: var(--gold);
    border-bottom-color: var(--gold);
}

.ui-toc-sep {
    color: var(--border-accent);
    font-size: .85rem;
    user-select: none;
}

/* ── SECTIONS ──────────────────────────────────────────────────────────────── */
.ui-section {
    padding: 5rem 2rem;
}

.ui-section-alt {
    background: rgba(255,255,255,0.02);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.ui-container {
    max-width: 960px;
    margin: 0 auto;
}

.ui-container-wide {
    max-width: 1600px;
}

.ui-section-title {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #fff;
    margin-bottom: 1.6rem;
    position: relative;
    padding-bottom: .75rem;
}

.ui-section-title::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0;
    width: 48px; height: 3px;
    background: var(--scarlet);
    border-radius: 2px;
}

.ui-section-desc {
    color: var(--text-muted);
    font-size: .92rem;
    margin-top: -.8rem;
    margin-bottom: 2rem;
}

.ui-section-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.6rem;
}

.ui-section-header .ui-section-title {
    margin-bottom: 0;
}

.ui-edit-btn {
    flex-shrink: 0;
}

/* ── LINKS GRID ────────────────────────────────────────────────────────────── */
.ui-links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.ui-link-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .6rem;
    padding: 1.5rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    text-decoration: none;
    color: var(--text);
    text-align: center;
    transition: background .15s, border-color .15s, transform .15s;
    min-height: 120px;
}

.ui-link-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--gold);
    transform: translateY(-3px);
    color: #fff;
}

.ui-link-card .ui-link-icon {
    font-size: 2rem;
    line-height: 1;
}

.ui-link-card .ui-link-label {
    font-weight: 600;
    font-size: .9rem;
    letter-spacing: .04em;
}

.ui-link-card .ui-link-sub {
    font-size: .75rem;
    color: var(--text-muted);
}

.ui-edit-row {
    margin-top: .75rem;
}

/* ── PROSE / RICH TEXT ─────────────────────────────────────────────────────── */
.ui-prose {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem 2.5rem;
    line-height: 1.8;
    color: var(--text);
    font-size: .95rem;
    white-space: pre-wrap;
    word-wrap: break-word;
    min-height: 80px;
}

.ui-prose-empty {
    color: var(--text-muted);
    font-style: italic;
}

/* ── FLOWCHART TABS ────────────────────────────────────────────────────────── */
.fc-tabs {
    display: flex;
    gap: .4rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: .75rem;
}

.fc-tab {
    padding: .45rem 1.1rem;
    border-radius: var(--radius) var(--radius) 0 0;
    border: 1px solid transparent;
    border-bottom: none;
    background: transparent;
    color: var(--text-muted);
    font-size: .82rem;
    font-weight: 500;
    cursor: pointer;
    transition: color .15s, background .15s, border-color .15s;
    letter-spacing: .03em;
}

.fc-tab:hover {
    color: var(--text);
    background: rgba(255,255,255,0.04);
}

.fc-tab.active {
    color: var(--gold);
    border-color: var(--border);
    background: var(--bg-card);
    border-bottom: 2px solid var(--gold);
    margin-bottom: -2px;
}

/* ── FLOWCHART PANEL ───────────────────────────────────────────────────────── */
.fc-panel {
    display: none;
    animation: fcPanelIn .3s ease both;
}

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

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

.fc-panel-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.fc-panel-title {
    flex: 1;
}

.fc-panel-title h3 {
    font-size: 1.15rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: .3rem;
}

.fc-panel-title p {
    font-size: .85rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* ── SVG CHART CONTAINER ───────────────────────────────────────────────────── */
.fc-svg-wrap {
    background: #0a0f1a;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
}

.fc-svg-wrap svg {
    display: block;
    width: 100%;
    height: auto;
}

/* ── SVG ANIMATION CLASSES ─────────────────────────────────────────────────── */
.fc-node {
    opacity: 0;
    transition: opacity .4s ease;
}

.fc-node.visible {
    opacity: 1;
}

.fc-edge {
    stroke-dasharray: var(--dash-len, 2000);
    stroke-dashoffset: var(--dash-len, 2000);
    transition: stroke-dashoffset 0.6s cubic-bezier(.4,0,.2,1);
}

.fc-edge.visible {
    stroke-dashoffset: 0;
}

.fc-textbox {
    opacity: 0;
    transition: opacity .5s ease;
}

.fc-textbox.visible {
    opacity: 1;
}

/* ── FLOWCHART EDITOR ──────────────────────────────────────────────────────── */
.fc-editor-section {
    margin-bottom: 1.5rem;
}

.fc-editor-section-title {
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: .75rem;
    padding-bottom: .4rem;
    border-bottom: 1px solid var(--border);
}

.fc-editor-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: .5rem;
    align-items: center;
    padding: .55rem .75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: .4rem;
}

.fc-editor-item-label {
    font-size: .85rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fc-editor-item-sub {
    font-size: .72rem;
    color: var(--text-muted);
}

.fc-color-swatch {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    border: 1px solid rgba(255,255,255,0.2);
    cursor: pointer;
    flex-shrink: 0;
}

.fc-editor-expand {
    background: rgba(255,255,255,0.06);
    border: none;
    color: var(--text-muted);
    font-size: .75rem;
    padding: .2rem .45rem;
    border-radius: var(--radius);
    cursor: pointer;
    flex-shrink: 0;
}

.fc-editor-expand:hover {
    color: var(--text);
    background: rgba(255,255,255,0.1);
}

.fc-editor-fields {
    display: none;
    padding: .75rem .75rem .5rem;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    margin-bottom: .4rem;
    margin-top: -.4rem;
}

.fc-editor-fields.open {
    display: block;
}

.fc-field-row {
    display: flex;
    gap: .5rem;
    align-items: center;
    margin-bottom: .5rem;
}

.fc-field-row label {
    font-size: .75rem;
    color: var(--text-muted);
    width: 90px;
    flex-shrink: 0;
}

.fc-field-row input[type="text"],
.fc-field-row textarea {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius);
    color: var(--text);
    font-size: .82rem;
    padding: .35rem .6rem;
    font-family: inherit;
}

.fc-field-row textarea {
    resize: vertical;
    min-height: 60px;
}

.fc-field-row input[type="color"] {
    width: 38px;
    height: 28px;
    padding: 1px 2px;
    background: var(--bg-card);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius);
    cursor: pointer;
}

/* ── RESPONSIVE ────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .ui-hero h1 { font-size: 1.6rem; }
    .ui-section { padding: 3rem 1rem; }
    .ui-prose { padding: 1.25rem 1.25rem; }
    .fc-tab { font-size: .75rem; padding: .38rem .75rem; }
}
