.graph-element-global-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px 0;
    padding: 8px 10px;
    border: 1px solid rgba(148, 163, 184, .35);
    border-radius: 10px;
    background: rgba(248, 250, 252, .78);
}
.graph-element-global-controls > span {
    margin-right: auto;
    font-weight: 750;
}
.graph-element-global-controls button,
.graph-element-add-source,
.graph-source-row-actions button,
.graph-source-tabs button {
    border: 1px solid rgba(100, 116, 139, .32);
    border-radius: 8px;
    background: Canvas;
    color: CanvasText;
    min-height: 34px;
    padding: 0 10px;
    cursor: pointer;
    font: inherit;
}
.graph-element-card {
    border: 1px solid rgba(148, 163, 184, .34);
    border-radius: 12px;
    overflow: clip;
    margin: 8px 0;
    background: Canvas;
}
.graph-element-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 8px 10px;
}
.graph-element-toggle {
    display: flex;
    gap: 9px;
    min-width: 0;
    align-items: center;
    width: 100%;
    border: 0;
    background: transparent;
    color: inherit;
    padding: 3px 0;
    text-align: left;
    cursor: pointer;
}
.graph-element-chevron {
    font-size: 22px;
    line-height: 1;
    transition: transform .12s ease;
}
.graph-element-card.is-open .graph-element-chevron {
    transform: rotate(90deg);
}
.graph-element-summary-main {
    min-width: 0;
    display: grid;
    gap: 2px;
}
.graph-element-summary-title {
    font-weight: 780;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.graph-element-summary-meta {
    font-size: .78rem;
    opacity: .66;
}
.graph-element-add-source {
    font-weight: 700;
}
.graph-element-body {
    padding: 4px 14px 16px;
    border-top: 1px solid rgba(148, 163, 184, .25);
}
.graph-element-body[hidden] {
    display: none !important;
}

.graph-source-dialog {
    width: min(900px, calc(100vw - 28px));
    max-height: min(82vh, 860px);
    padding: 0;
    border: 1px solid rgba(100, 116, 139, .35);
    border-radius: 16px;
    background: Canvas;
    color: CanvasText;
    box-shadow: 0 28px 90px rgba(0, 0, 0, .28);
}
.graph-source-dialog::backdrop {
    background: rgba(15, 23, 42, .48);
}
.graph-source-dialog-shell {
    display: grid;
    grid-template-rows: auto auto auto minmax(160px, 1fr) auto;
    max-height: min(82vh, 860px);
}
.graph-source-dialog-header {
    display: flex;
    gap: 20px;
    justify-content: space-between;
    align-items: start;
    padding: 18px 20px 12px;
}
.graph-source-dialog-header h2 {
    margin: 3px 0 4px;
}
.graph-source-dialog-header p {
    margin: 0;
    opacity: .7;
}
.graph-source-dialog-kicker {
    text-transform: uppercase;
    letter-spacing: .07em;
    font-weight: 800;
    font-size: .72rem;
    opacity: .6;
}
.graph-source-dialog-close {
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
}
.graph-source-tabs {
    display: flex;
    gap: 7px;
    padding: 0 20px 10px;
}
.graph-source-tabs button[aria-selected="true"] {
    background: CanvasText;
    color: Canvas;
}
.graph-source-search {
    display: grid;
    gap: 5px;
    padding: 0 20px 12px;
    font-size: .78rem;
    font-weight: 700;
}
.graph-source-search input {
    width: 100%;
    min-height: 40px;
    border: 1px solid rgba(100, 116, 139, .35);
    border-radius: 9px;
    background: Canvas;
    color: CanvasText;
    padding: 0 11px;
    font: inherit;
}
.graph-source-results {
    overflow: auto;
    padding: 0 20px 16px;
}
.graph-source-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px;
    align-items: center;
    padding: 12px 0;
    border-top: 1px solid rgba(148, 163, 184, .23);
}
.graph-source-row-copy {
    min-width: 0;
    display: grid;
    gap: 4px;
}
.graph-source-row-copy strong {
    line-height: 1.35;
}
.graph-source-row-copy span {
    font-size: .76rem;
    opacity: .62;
    word-break: break-word;
}
.graph-source-row-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: end;
}
.graph-source-row-actions button.is-saved {
    font-weight: 800;
}
.graph-source-empty {
    padding: 28px 6px;
    text-align: center;
    opacity: .67;
}
.graph-source-error {
    opacity: 1;
}
.graph-source-dialog-footer {
    border-top: 1px solid rgba(148, 163, 184, .24);
    padding: 10px 20px 14px;
    font-size: .76rem;
    opacity: .67;
}
@media (max-width: 720px) {
    .graph-element-summary {
        grid-template-columns: 1fr;
    }
    .graph-element-add-source {
        justify-self: start;
    }
    .graph-source-row {
        grid-template-columns: 1fr;
    }
    .graph-source-row-actions {
        justify-content: start;
    }
}

/* -------------------------------------------------------------------------
   V1.2 graph element alignment
   The original graph template defines .element-row as a three-column grid.
   Once V1 promotes that node to .graph-element-card, the new summary/body
   must span the whole card instead of becoming cells in the legacy grid.
   ------------------------------------------------------------------------- */
.element-row.graph-element-card {
    display: block;
    grid-template-columns: none;
    gap: 0;
    align-items: stretch;
    padding: 0;
    border-bottom: 0;
}

.element-row.graph-element-card > .graph-element-summary,
.element-row.graph-element-card > .graph-element-body {
    width: 100%;
    min-width: 0;
}

.element-row.graph-element-card > .graph-element-summary {
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 12px;
    align-items: center;
    min-height: 52px;
    padding: 8px 10px 8px 8px;
}

.element-row.graph-element-card .graph-element-toggle {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr);
    gap: 8px;
    align-items: center;
    min-width: 0;
    padding: 0;
}

.element-row.graph-element-card .graph-element-chevron {
    width: 22px;
    text-align: center;
    justify-self: center;
    flex: none;
}

.element-row.graph-element-card .graph-element-summary-main {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) auto;
    column-gap: 16px;
    align-items: center;
    min-width: 0;
}

.element-row.graph-element-card .graph-element-summary-title {
    min-width: 0;
    line-height: 1.25;
}

.element-row.graph-element-card .graph-element-summary-meta {
    justify-self: end;
    white-space: nowrap;
    line-height: 1.25;
}

.element-row.graph-element-card .graph-element-add-source {
    justify-self: end;
    align-self: center;
    white-space: nowrap;
    min-width: 88px;
}

.element-row.graph-element-card > .graph-element-body {
    box-sizing: border-box;
    grid-template-columns: 22px minmax(0, 1fr) auto;
    gap: 8px;
    align-items: start;
    padding: 10px 12px 14px 10px;
}

.element-row.graph-element-card.is-open > .graph-element-body {
    display: grid;
}

.element-row.graph-element-card > .graph-element-body[hidden] {
    display: none !important;
}

@media (max-width: 900px) {
    .element-row.graph-element-card .graph-element-summary-main {
        grid-template-columns: minmax(0, 1fr);
        row-gap: 3px;
    }

    .element-row.graph-element-card .graph-element-summary-meta {
        justify-self: start;
        white-space: normal;
    }
}

@media (max-width: 600px) {
    .element-row.graph-element-card > .graph-element-summary {
        grid-template-columns: minmax(0, 1fr);
        row-gap: 8px;
        padding: 9px 10px;
    }

    .element-row.graph-element-card .graph-element-add-source {
        justify-self: start;
        margin-left: 30px;
    }

    .element-row.graph-element-card.is-open > .graph-element-body {
        grid-template-columns: 20px minmax(0, 1fr);
    }

    .element-row.graph-element-card > .graph-element-body > span:last-child {
        grid-column: 2;
    }
}

