/* kornia.org/playground: two-pane shell (operator list left, demo right) and the widget.
   Colours and type come from ../styles.css tokens. */

/* same treatment index.html gives the wordmark in its inline styles */
.pg-body .logo a,
.pg-body .logo a:hover,
.pg-body .logo a:visited {
    color: var(--text-secondary);
    text-decoration: none;
}

/* ---- shell ---- */

.pg-shell {
    display: grid;
    grid-template-columns: 17rem minmax(0, 1fr);  /* list | content */
    max-width: 1400px;
    margin: 0 auto;
    padding: 5.5rem 1.5rem 3rem;  /* the site header is fixed; clear it */
    min-height: 80vh;
}

@media (max-width: 899px) {
    .pg-shell {
        grid-template-columns: minmax(0, 1fr);
        padding: 5rem 1rem 2rem;
    }
}

.pg-side {
    position: sticky;
    top: 5rem;
    align-self: start;
    max-height: calc(100vh - 6rem);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    padding-right: 1.25rem;
    margin-right: 1.75rem;
}

@media (max-width: 899px) {
    .pg-side {
        position: static;
        max-height: none;
        border-right: none;
        padding-right: 0;
        margin: 0 0 1.5rem;
    }
}

.pg-side-lead {
    margin: 0.25rem 0 0.9rem;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

.pg-search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    background: var(--background-color);
    color: var(--text-muted);
}

.pg-search input {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    font: inherit;
    font-size: 0.9rem;
    color: var(--text-primary);
    background: transparent;
}

.pg-filters {
    display: flex;
    gap: 0.35rem;
    margin: 0.6rem 0 0.4rem;
}

.pg-filters label {
    padding: 0.2rem 0.65rem;
    border: 1px solid var(--border-color);
    border-radius: 2px;
    font-size: 0.78rem;
    cursor: pointer;
    color: var(--text-secondary);
}

.pg-filters label:has(input:checked) {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: var(--primary-soft);
}

.pg-filters input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.pg-meta {
    margin: 0 0 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.pg-side-list {
    overflow-y: auto;
    flex: 1 1 auto;
    padding-right: 0.25rem;
    scrollbar-width: thin;
}

.pg-pkg {
    margin: 0.5rem 0 0.9rem;
}

.pg-pkg h2 {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0 0 0.25rem;
    padding: 0.35rem 0.5rem 0;
}

.pg-pkg-count {
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
    font-variant-numeric: tabular-nums;
}

.pg-list {
    list-style: none;
    margin: 0;
    padding: 0 0 0 0.6rem;  /* entries sit indented under their category heading */
}

.pg-row-name {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.28rem 0.5rem;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-primary);
    text-decoration: none;
    overflow-wrap: anywhere;
}

.pg-row-name:hover {
    background: var(--surface-color);
    color: var(--primary-color);
}

.pg-row-name.pg-row-current {
    background: var(--primary-soft);
    color: var(--primary-color);
    font-weight: 600;
}

.pg-row-unsupported .pg-row-name {
    color: var(--text-muted);
}

.pg-row-unsupported .pg-row-name:hover {
    color: var(--text-secondary);
}

.pg-tag {
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 0.15rem 0.5rem;
    border-radius: 2px;
    background: var(--warn-bg);
    color: var(--warn-text);
    white-space: nowrap;
}

.pg-tag-small {
    font-size: 0.58rem;
    padding: 0.05rem 0.35rem;
    font-family: var(--font-body);
}

/* ---- detail pane ---- */

.pg-detail {
    min-width: 0;
}

.pg-op {
    padding: 0 0 1rem;
}

.pg-op-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem 1rem;
    margin-bottom: 0.25rem;
}

.pg-head h1,
.pg-head h2,
.pg-op-head h1 {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    line-height: 1.2;
    margin: 0;
    color: var(--text-primary);
}

.pg-op-head code {
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    padding: 0.15rem 0.5rem;
    border-radius: 2px;
}

.pg-op-head .pg-tag {
    margin-left: auto;
}

.pg-summary {
    margin: 0 0 1.5rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.55;
}

.pg-summary a {
    color: var(--primary-color);
}

.pg-op-unsupported .pg-op-head h2 {
    color: var(--text-muted);
}

/* the stage template: stage | control bar | parameters | code | details, one column */
.pg-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
        "images"
        "bar"
        "controls"
        "code"
        "details";
    gap: 1rem;
    align-items: start;
}

.pg-cell-images { grid-area: images; }
.pg-cell-bar { grid-area: bar; }
.pg-cell-controls { grid-area: controls; }
.pg-code { grid-area: code; margin-top: 0.25rem; }
.pg-cell-details { grid-area: details; margin-top: 0; }

/* the row under the stage: samples on the left, the actions on the right */
.pg-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem 1.5rem;
}

.pg-bar .pg-actions {
    margin: 0;
    justify-content: flex-end;
    flex: 1 1 auto;
    min-height: 60px;   /* one thumbnail row: the buttons sit level with the pictures */
}

.pg-bar .pg-thumbs {
    display: block;
    margin: 0;
}

.pg-actions .pg-where {
    margin: 0;
    align-items: center;
    font-size: 0.85rem;
}

.pg-actions .pg-status {
    flex-basis: 100%;
    text-align: right;
}

/* the parameters panel */
.pg-cell-controls {
    padding: 0.9rem 1.1rem;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    background: var(--surface-color);
}

.pg-model-panel:not(:has(> :not([hidden]))) {
    display: none;
}

/* a toggle switch for the checkboxes that pick where things run */
.pg-switch {
    appearance: none;
    -webkit-appearance: none;
    width: 2rem;
    height: 1.1rem;
    margin: 0;
    border-radius: 2px;
    background: var(--border-color);
    position: relative;
    cursor: pointer;
    flex: none;
    transition: background 0.15s ease;
}

.pg-switch::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: calc(1.1rem - 4px);
    height: calc(1.1rem - 4px);
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
    transition: transform 0.15s ease;
}

.pg-switch:checked {
    background: var(--primary-color);
}

.pg-switch:checked::after {
    transform: translateX(0.9rem);
}

.pg-switch:disabled {
    opacity: 0.5;
    cursor: default;
}

.pg-switch:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

.pg-images {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.pg-images figure {
    margin: 0;
}

.pg-images canvas,
.pg-images img {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 3px;
    background: var(--surface-color);
    image-rendering: auto;
}

/* a server result keeps the image's own aspect ratio inside the square */
.pg-images img.pg-contain {
    object-fit: contain;
}

/* ``display: block`` above would otherwise beat the ``hidden`` attribute */
.pg-images [hidden] {
    display: none !important;
}

.pg-images figcaption {
    margin-top: 0.35rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    text-align: center;
}

.pg-thumbs {
    display: flex;
    gap: 1rem;
    margin-top: 0.75rem;
    align-items: flex-start;  /* thumbnails share the top edge; the guidance label hangs below */
}

/* images, then the upload button, then the clips: a left-aligned 2x4 grid that cannot overflow */
.pg-thumbs-pick {
    display: grid;
    grid-template-columns: repeat(4, 56px);
    gap: 0.5rem;
    justify-content: start;
}

.pg-thumbs button {
    padding: 0;
    border: 2px solid transparent;
    border-radius: 3px;
    background: none;
    cursor: pointer;
    line-height: 0;
}

.pg-thumbs button img {
    width: 56px;
    height: 56px;
    border-radius: 4px;
    object-fit: cover;
}

.pg-thumbs button.pg-selected {
    border-color: var(--primary-color);
}

.pg-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem 2rem;
}

.pg-controls > .pg-note {
    grid-column: 1 / -1;
}

@media (max-width: 760px) {
    .pg-controls {
        grid-template-columns: minmax(0, 1fr);
    }
}

.pg-param {
    display: grid;
    grid-template-columns: 8.5rem minmax(0, 1fr) 4.5rem;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
}

.pg-param label {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-primary);
    overflow-wrap: anywhere;
}

.pg-param input[type="range"] {
    width: 100%;
    accent-color: var(--primary-color);
}

.pg-param select {
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    font: inherit;
    font-size: 0.85rem;
    background: var(--background-color);
}

.pg-param output {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    text-align: right;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.pg-param.pg-fixed label,
.pg-param.pg-fixed output,
.pg-param.pg-fixed span {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.pg-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.25rem;
}

.pg-btn {
    padding: 0.45rem 1.1rem;
    border: none;
    border-radius: 3px;
    background: var(--primary-color);
    color: #fff;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

.pg-btn:hover {
    background: var(--secondary-color);
}

.pg-btn.pg-btn-ghost {
    background: var(--surface-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.pg-btn.pg-btn-ghost:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: var(--background-color);
}

.pg-status {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.pg-status.pg-error {
    color: #b91c1c;
}

.pg-note {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0;
}

/* code tabs */
.pg-code {
    border-radius: 3px;
    overflow: hidden;
    background: var(--code-bg);
}

.pg-tabs {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.4rem 0.5rem 0;
    background: var(--code-bg-2);
}

.pg-tab {
    padding: 0.4rem 0.9rem;
    border: none;
    border-radius: 3px 6px 0 0;
    background: transparent;
    color: #94a3b8;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}

.pg-tab:hover {
    color: #e2e8f0;
}

.pg-tab.pg-tab-active {
    background: var(--code-bg);
    color: #fff;
}

.pg-tabs .pg-copy {
    margin-left: auto;
    margin-bottom: 0.4rem;
    padding: 0.2rem 0.6rem;
    border: 1px solid #334155;
    border-radius: 3px;
    background: var(--code-bg);
    color: #cbd5e1;
    font: inherit;
    font-size: 0.72rem;
    cursor: pointer;
}

.pg-tabs .pg-copy:hover {
    color: #fff;
    border-color: #64748b;
}

.pg-pane pre {
    margin: 0;
    padding: 0.9rem 1rem;
    color: #e2e8f0;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    line-height: 1.5;
    overflow-x: auto;
}

/* highlight.js (github-dark theme) colours the tokens; the box keeps its own background */
.pg-pane pre code.hljs {
    padding: 0;
    background: transparent;
    font-family: inherit;
    font-size: inherit;
}

.pg-pane pre.pg-pre-empty {
    color: #94a3b8;
}

/* styles.css lays out ``nav`` as a flex row for the site header; the sidebar list is a plain block */
.pg-side nav.pg-side-list {
    display: block;
    position: static;
    padding: 0 0.25rem 0 0;
    background: none;
    box-shadow: none;
    max-width: none;
}

/* narrow screens: the demo first, the operator list below it in its own scroll box */
@media (max-width: 899px) {
    .pg-detail {
        order: -1;
        margin-bottom: 1.5rem;
    }

    .pg-side nav.pg-side-list {
        max-height: 50vh;
        overflow-y: auto;
        border: 1px solid var(--border-color);
        border-radius: 3px;
        padding: 0.25rem 0.5rem;
    }
}

/* fixed guidance image: in the picker row, under the output, same size as the sample thumbnails */
.pg-guide {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-self: center;
    gap: 0.2rem;
    font-size: 0.68rem;
    color: var(--text-muted);
    cursor: default;
}

.pg-thumbs .pg-guide-thumb {
    width: 56px;
    height: 56px;
    border-radius: 4px;
    border: 2px solid var(--border-color);
    object-fit: cover;
}

.pg-thumbs .pg-guide-large {
    display: none;
    position: absolute;
    left: 50%;
    bottom: calc(100% + 0.4rem);
    transform: translateX(-50%);
    width: 160px;
    height: 160px;
    border-radius: 3px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    background: var(--background-color);
    z-index: 5;
}

.pg-guide:hover .pg-guide-large {
    display: block;
}

/* sponsor block at the bottom of the sidebar (same copy as the docs sidebar) */
.pg-sponsors {
    flex: 0 0 auto;
    margin-top: 0.75rem;
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    font-size: 0.78rem;
    line-height: 1.45;
    color: var(--text-secondary);
}

.pg-sponsors p {
    margin: 0 0 0.4rem;
}

.pg-sponsors p:last-child {
    margin-bottom: 0;
}

.pg-sponsors__title {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.68rem;
    color: var(--text-muted);
}

.pg-sponsors a {
    color: var(--primary-color);
    text-decoration: none;
}

.pg-sponsors a:hover {
    text-decoration: underline;
}

/* ---- right sidebar: on this page, links, sponsors ---- */

.pg-right {
    position: sticky;
    top: 5rem;
    align-self: start;
    max-height: calc(100vh - 6rem);
    overflow-y: auto;
    border-left: 1px solid var(--border-color);
    padding-left: 1.25rem;
    margin-left: 1.75rem;
    font-size: 0.85rem;
}

.pg-right-item + .pg-right-item {
    margin-top: 1.25rem;
}

.pg-right-title {
    margin: 0 0 0.4rem;
    font-weight: 500;
    color: var(--text-primary);
}

.pg-right-title i {
    margin-right: 0.35rem;
    color: var(--text-muted);
}

.pg-toc {
    list-style: none;
    margin: 0;
    padding: 0 0 0 0.25rem;
}

.pg-toc li {
    margin: 0.3rem 0;
}

.pg-toc a,
.pg-right-links a {
    color: var(--text-secondary);
    text-decoration: none;
}

.pg-toc a:hover,
.pg-right-links a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.pg-right-links {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.pg-right-links a {
    color: var(--primary-color);
}

.pg-right-links i {
    width: 1.1rem;
    margin-right: 0.15rem;
    color: var(--text-muted);
}

.pg-right .pg-sponsors {
    margin-top: 0;
}

@media (max-width: 1199px) {
    .pg-shell {
        grid-template-columns: 17rem minmax(0, 1fr);
    }

    .pg-right {
        grid-column: 2;
        position: static;
        max-height: none;
        border-left: none;
        padding-left: 0;
        margin: 1.5rem 0 0 1.75rem;
        display: flex;
        flex-wrap: wrap;
        gap: 1.5rem;
    }

    .pg-right-item + .pg-right-item {
        margin-top: 0;
    }
}

@media (max-width: 899px) {
    .pg-shell {
        grid-template-columns: minmax(0, 1fr);
    }

    .pg-right {
        grid-column: 1;
        margin-left: 0;
    }
}

/* ---- pipelines ---- */

.pg-pipe-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
    margin-bottom: 0.5rem;
}

.pg-pipe-head h2 {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.pg-pipe-head .pg-btn {
    margin-left: auto;
}

.pg-input {
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    font: inherit;
    color: var(--text-primary);
    background: var(--background-color);
}

.pg-pipe-title {
    font-size: 1.3rem;
    font-weight: 700;
    min-width: 14rem;
    flex: 1 1 14rem;
}

.pg-pipe-container {
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: var(--surface-color);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.pg-pipe-namerow {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0 0 1rem;
    font-size: 0.9rem;
}

.pg-pipe-namerow .pg-input {
    flex: 1 1 auto;
    max-width: 24rem;
}

.pg-pipe-grid {
    display: flex;
    flex-direction: column;  /* one full-width card per pipeline */
    gap: 0.75rem;
    margin: 1rem 0;
}

.pg-pipe-create {
    padding: 0;
    border-style: dashed;
}

.pg-pipe-create-open,
.pg-pipe-create:hover {
    border-color: var(--primary-color);
}

.pg-pipe-create-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.85rem 1rem;
    border: none;
    background: none;
    color: var(--primary-color);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.pg-pipe-create-btn:hover {
    background: var(--primary-soft);
}

.pg-pipe-create-form {
    padding: 0.25rem 1.1rem 1rem;
    border-top: 1px dashed var(--border-color);
}

.pg-pipe-create-form .pg-note {
    margin: 0.5rem 0 0.5rem;
}

.pg-pipe-choices {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));  /* the three containers side by side */
    gap: 0.6rem;
}

@media (max-width: 760px) {
    .pg-pipe-choices {
        grid-template-columns: minmax(0, 1fr);
    }
}

.pg-pipe-choice {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.3rem;
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    background: var(--background-color);
    text-align: left;
    font: inherit;
    cursor: pointer;
}

.pg-pipe-choice:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
}

.pg-pipe-choice code {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--primary-color);
}

.pg-pipe-choice .pg-note {
    margin: 0;
    font-size: 0.78rem;
}

.pg-pipe-card {
    border: 1px solid var(--border-color);
    border-radius: 3px;
    background: var(--background-color);
    padding: 1rem 1.1rem;
    text-align: left;
    font: inherit;
}

.pg-pipe-card .pg-note {
    margin: 0.25rem 0;
}

.pg-pipe-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
}

.pg-pipe-name:hover {
    color: var(--primary-color);
}

.pg-pipe-steps {
    margin: 0.4rem 0 0.6rem;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-secondary);
    overflow-wrap: anywhere;
}

.pg-pipe-actions {
    display: flex;
    gap: 0.75rem;
}

.pg-link {
    padding: 0;
    border: none;
    background: none;
    font: inherit;
    font-size: 0.82rem;
    color: var(--primary-color);
    cursor: pointer;
}

.pg-link:hover {
    text-decoration: underline;
}

.pg-link:disabled {
    color: var(--text-muted);
    cursor: default;
    text-decoration: none;
}

.pg-link-danger {
    color: #b91c1c;
}

/* editor: preview, steps, actions, then code, each full width */
.pg-pipe-layout {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin: 1rem 0;
}

/* preview: sample picker as a column on the left, input and output side by side */
.pg-pipe-preview-row {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 0.9rem;
}

.pg-pipe-thumbs {
    display: block;
    margin: 0;
}

.pg-pipe-pick {
    /* beside the preview: images down the first column, clips down the second */
    grid-template-columns: repeat(2, 56px);
    grid-template-rows: repeat(3, 56px);
    grid-auto-flow: column;
    align-content: start;
}

.pg-pipe-images {
    flex: 0 1 40rem;
    min-width: 0;
}

@media (max-width: 640px) {
    .pg-pipe-preview-row {
        flex-direction: column;
        align-items: stretch;
    }

    .pg-pipe-pick {
        flex-direction: row;
    }
}

.pg-pipe-actions-block .pg-actions {
    margin-top: 0;
}

.pg-pipe-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

/* one row per step: number | name | parameters | tools */
.pg-pipe-step {
    display: grid;
    grid-template-columns: 1.4rem 11rem minmax(0, 1fr) auto;
    align-items: start;  /* name stays top-left when the parameters stack */
    gap: 0.4rem 0.9rem;
    padding: 0.5rem 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    background: var(--background-color);
}

.pg-pipe-step:hover {
    border-color: #c7d2fe;
}

.pg-pipe-step-num {
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 50%;
    background: var(--surface-color);
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.pg-pipe-step-params {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 0;
}

.pg-pipe-step-params .pg-note {
    margin: 0;
}

/* fixed columns so every label, control and value line up across a step's parameters */
.pg-pipe-param {
    display: grid;
    grid-template-columns: 7.5rem 12rem 3rem;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
}

.pg-pipe-param select,
.pg-pipe-param input[type="range"] {
    width: 100%;
    box-sizing: border-box;
}

.pg-pipe-param output {
    text-align: right;
}

.pg-pipe-param label {
    color: var(--text-secondary);
    font-size: 0.78rem;
}

.pg-pipe-param select {
    padding: 0.15rem 0.35rem;
    font-size: 0.8rem;
}

@media (max-width: 899px) {
    .pg-pipe-step {
        grid-template-columns: 1.4rem minmax(0, 1fr) auto;
    }

    .pg-pipe-step-params {
        grid-column: 2 / -1;
    }
}

.pg-pipe-step-name {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
    line-height: 1.6rem;  /* sits on the first parameter's baseline */
    overflow-wrap: anywhere;
}

.pg-pipe-step-num,
.pg-pipe-step-tools {
    margin-top: 0.1rem;
}

.pg-pipe-step-name:hover {
    color: var(--primary-color);
}

.pg-pipe-step-tools {
    display: flex;
    gap: 0.6rem;
}

.pg-pipe-add {
    margin-top: 0.75rem;
}

.pg-select {
    width: 100%;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    font: inherit;
    font-size: 0.9rem;
    background: var(--background-color);
}

.pg-pipe-warnings {
    margin: 0.75rem 0 0;
    padding-left: 1.1rem;
    font-size: 0.8rem;
    color: var(--warn-text);
}

.pg-pipe-warnings:empty {
    display: none;
}

.pg-pipe-actions-row {
    margin-top: 0.75rem;
}

.pg-pipe-preview .pg-status {
    display: block;
    margin-top: 0.5rem;
}

.pg-pipe-code {
    margin-top: 0.5rem;
}

.pg-pipe-code .pg-tab {
    cursor: default;
}

.pg-pipe-choice code,
.pg-pipe-container {
    white-space: normal;
    overflow-wrap: anywhere;
}

.pg-input:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 1px;
    border-color: var(--primary-color);
}

/* video samples in the picker: a play badge over the poster */
.pg-thumbs button.pg-thumb-video {
    position: relative;
}

.pg-thumb-play {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.8rem;
    pointer-events: none;
}

.pg-thumb-play i {
    background: rgba(15, 23, 42, 0.6);
    border-radius: 50%;
    width: 1.5rem;
    height: 1.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding-left: 0.1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}


/* ---- Operators | Models switch ---- */
.pg-mode {
    display: flex;
    gap: 0.25rem;
    padding: 0.2rem;
    margin-bottom: 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    background: var(--surface-color);
}

.pg-mode button {
    flex: 1;
    padding: 0.4rem 0.25rem;
    border: none;
    border-radius: 3px;
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.pg-mode button[aria-selected="true"] {
    background: var(--card-bg);
    color: var(--text-primary);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.pg-side nav.pg-models-list {
    display: block;
}

.pg-model-task {
    margin: 0.5rem 0 0.2rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.pg-row-name.pg-row-model {
    flex-direction: column;
    align-items: stretch;
    gap: 0.1rem;
    padding: 0.35rem 0.5rem;
}

.pg-model-title {
    font-weight: 600;
}

.pg-model-sub {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    font-family: Inter, system-ui, sans-serif;
    font-size: 0.74rem;
    font-weight: 400;
    color: var(--text-muted);
}

.pg-row-current .pg-model-sub {
    color: var(--primary-color);
}

.pg-model-size {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* ---- Model widget ---- */
.pg-model-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.3rem;
}

.pg-model-head h1 {
    margin: 0;
}

.pg-tag-task {
    background: rgba(37, 99, 235, 0.08);
    color: var(--primary-color);
}

.pg-model-stage {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: start;
}

.pg-model-stage figure {
    margin: 0;
}

.pg-model-stage canvas {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 3px;
    border: 1px solid var(--border-color);
    background: var(--code-bg);
}

.pg-model-stage figcaption {
    margin-top: 0.35rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
}

.pg-model-actions {
    margin-top: 0;
}

.pg-model-thumbs {
    margin-top: 0.75rem;
}

.pg-progress {
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    overflow: hidden;
    margin: 0.3rem 0 0.8rem;
}

.pg-progress > div {
    height: 100%;
    width: 0;
    background: var(--primary-color);
    transition: width 0.15s linear;
}

.pg-model-param {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.pg-model-param input[type="range"] {
    width: 9rem;
}

.pg-model-card {
    margin-top: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    overflow: hidden;
}

.pg-model-card table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.pg-model-card th,
.pg-model-card td {
    padding: 0.55rem 0.8rem;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--border-light);
}

.pg-model-card th {
    width: 9rem;
    color: var(--text-muted);
    font-weight: 600;
    background: var(--surface-color);
}

.pg-model-card tr:last-child th,
.pg-model-card tr:last-child td {
    border-bottom: none;
}

@media (max-width: 700px) {
    .pg-model-stage {
        grid-template-columns: 1fr;
    }
}


/* hidden must win over the sidebar's display overrides when the Models tab is active */
.pg-side nav.pg-side-list[hidden],
.pg-side .pg-filters[hidden],
.pg-side .pg-meta[hidden] {
    display: none !important;
}

.pg-model-thumbs {
    display: grid;
    grid-template-columns: repeat(4, 56px);
    justify-content: start;
    gap: 0.5rem;
    margin: 0.8rem 0 0;
}


/* ---- Load-before-run dialog ---- */
.pg-dialog {
    /* the site reset zeroes margins, which would pin the dialog to the top-left corner */
    position: fixed;
    inset: 0;
    margin: auto;
    width: min(30rem, calc(100vw - 2rem));
    height: fit-content;
    max-width: 30rem;
    padding: 1.4rem 1.6rem;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
    color: var(--text-primary);
}

.pg-dialog::backdrop {
    background: rgba(15, 23, 42, 0.45);
}

.pg-dialog h2 {
    margin: 0 0 0.6rem;
    font-size: 1.15rem;
}

.pg-dialog p {
    margin: 0 0 0.7rem;
    color: var(--text-secondary);
    font-size: 0.93rem;
    line-height: 1.5;
}

.pg-dialog-warn {
    padding: 0.6rem 0.8rem;
    border-radius: 3px;
    background: var(--warn-bg);
    color: var(--warn-text) !important;
}

.pg-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    margin-top: 1rem;
}


/* feature models: the output is the frame and its warped copy side by side */
.pg-model-stage-wide {
    grid-template-columns: 1fr 2fr;
}


.pg-pipe-step-model .pg-pipe-step-name {
    font-weight: 700;
}

.pg-pipe-step-params .pg-tag-task {
    align-self: center;
}


/* ---- pipeline: the optional model block under the steps ---- */
.pg-pipe-model {
    margin-top: 1rem;
    padding: 0.9rem 1rem;
    border: 1px dashed var(--border-color);
    border-radius: 3px;
    background: var(--surface-color);
}

.pg-pipe-model-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
}

.pg-pipe-model-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
}

.pg-pipe-model-label .pg-note {
    font-weight: 400;
}

.pg-pipe-model-head .pg-select {
    flex: 1;
    min-width: 16rem;
}

.pg-pipe-model-info {
    margin: 0.7rem 0 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.pg-pipe-model-info a {
    color: var(--text-primary);
    font-weight: 600;
    text-decoration: none;
}

.pg-pipe-model-info .pg-tag {
    vertical-align: middle;
}


/* ---- robot page ---- */
/* ---- robot page: the view on the left, the three camera feeds stacked on the right ---- */
.rb-stage {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 172px;
    gap: 1rem;
    align-items: stretch;
    margin-top: 0.75rem;
}

.rb-view {
    position: relative;
    min-height: 320px;
    border-radius: 3px;
    border: 1px solid var(--border-color);
    background: #0b1220;
    overflow: hidden;
}

.rb-view canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.rb-hud {
    position: absolute;
    left: 0.6rem;
    bottom: 0.6rem;
    margin: 0;
    padding: 0.2rem 0.55rem;
    border-radius: 3px;
    background: rgba(11, 18, 32, 0.7);
    color: #cbd5e1;
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    max-width: calc(100% - 1.2rem);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rb-hud.pg-error {
    color: #fecaca;
}

.rb-feeds {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.rb-feeds figure {
    margin: 0;
}

.rb-feeds canvas {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    border-radius: 3px;
    border: 1px solid var(--border-color);
    background: var(--code-bg);
}

.rb-feeds figcaption {
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

.rb-pipe-tools {   /* under the perception menu when a pipeline is chosen */
    display: block;
    margin-top: 0.3rem;
    font-size: 0.72rem;
}

.rb-sensors {
    margin: 0 0 1rem;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    background: var(--surface-color);
}

.rb-sensors > summary {
    cursor: pointer;
    padding: 0.5rem 0.75rem;
    font-weight: 600;
    font-size: 0.85rem;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.rb-sensors > summary::-webkit-details-marker { display: none; }

.rb-sensors-count:not(:empty) {
    display: inline-grid;
    place-items: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: var(--accent-color);
    color: #0b1a2b;
    font-size: 0.72rem;
    font-weight: 700;
}

.rb-sensors-hint {
    margin-left: auto;
    font-weight: 400;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.rb-sensor-rows {
    padding: 0.25rem 0.75rem 0.75rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 0.5rem 1.5rem;
}

.rb-sensor {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0.6rem;
}

.rb-sensor-name {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.82rem;
    white-space: nowrap;
    cursor: pointer;
}

.rb-sensor input[type="range"] { width: 100%; margin: 0; }

.rb-sensor output {
    font-size: 0.75rem;
    color: var(--text-muted);
    min-width: 3.2rem;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.rb-sensor.is-off .rb-sensor-name,
.rb-sensor.is-off output { opacity: 0.5; }

@media (max-width: 640px) {
    .rb-sensors-hint { display: none; }
}

.rb-select {
    width: 100%;
    padding: 0.25rem 0.4rem;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    background: var(--background-color);
    color: var(--text-primary);
    font: inherit;
    font-size: 0.78rem;
}

@media (max-width: 760px) {
    .rb-stage {
        grid-template-columns: minmax(0, 1fr);
    }

    .rb-view {
        aspect-ratio: 2 / 1;
        min-height: 0;
    }

    .rb-feeds {
        flex-direction: row;
    }

    .rb-feeds figure {
        flex: 1 1 0;
        min-width: 0;
    }
}

.rb-bar {
    margin-top: 0;
    margin-bottom: 0.75rem;
    align-items: center;
}

.rb-bar .pg-actions {
    min-height: 0;
}

.rb-panel {
    margin: 0 0 0.75rem;
}

/* the arm's four sliders share one row */
.rb-sliders {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.5rem 1.25rem;
}

.rb-sliders .pg-param {
    grid-template-columns: auto minmax(0, 1fr) 3rem;
    gap: 0.5rem;
}

@media (max-width: 900px) {
    .rb-sliders {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.rb-keys {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.rb-keys kbd {
    display: inline-block;
    min-width: 1.4rem;
    padding: 0.1rem 0.35rem;
    border: 1px solid var(--border-color);
    border-bottom-width: 2px;
    border-radius: 5px;
    background: var(--card-bg);
    font-family: inherit;
    font-size: 0.75rem;
    text-align: center;
}

.rb-keys kbd + kbd {
    margin-left: -0.2rem;
}

.rb-keys .pg-note {
    margin-left: 0.5rem;
}

.rb-toggle {
    font-weight: 600;
    color: var(--text-primary);
}

.pg-controls-cell {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.pg-controls-cell .pg-where {
    margin: 0;
    align-items: center;
}

/* the display rules on flex/grid children would otherwise beat the ``hidden`` attribute */
.pg-shell [hidden] {
    display: none !important;
}

.pg-where-note {
    margin: 0;
}

.pg-quota-line {
    margin-top: 0.2rem;
}


/* where a model runs: the visitor's choice, above the Run button */
.pg-where {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin: 0.9rem 0 0.2rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.pg-where input {
    margin-top: 0.2rem;
    accent-color: var(--primary-color);
}

.pg-where input:disabled + span {
    color: var(--text-muted);
}

.pg-pipe-where {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.6rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.pg-pipe-where input {
    accent-color: var(--primary-color);
}


/* upload-your-own-image thumbnail: dashed, greyed until signed in */
.pg-thumbs button.pg-thumb-upload,
.pg-thumbs-pick button.pg-thumb-upload {
    position: relative;
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
    border: 2px dashed var(--border-color);
    border-radius: 3px;
    background: var(--surface-color);
    color: var(--primary-color);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
}

.pg-thumbs button.pg-thumb-upload:hover,
.pg-thumbs-pick button.pg-thumb-upload:hover {
    border-color: var(--primary-color);
}

.pg-thumbs button.pg-thumb-upload.is-locked,
.pg-thumbs-pick button.pg-thumb-upload.is-locked {
    color: var(--text-muted);
    opacity: 0.6;
}

.pg-thumbs button.pg-thumb-upload.is-locked::after,
.pg-thumbs-pick button.pg-thumb-upload.is-locked::after {
    content: "\f023";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 0.6rem;
    position: absolute;
    right: 5px;
    bottom: 4px;
}

.pg-thumbs-pick {
    grid-auto-rows: 56px;
}

/* ---- pipelines sidebar ---- */
.pg-row-name.pg-row-new .pg-model-title {
    color: var(--primary-color);
}

.pg-pipe-head-actions {
    display: flex;
    gap: 0.9rem;
    margin-left: auto;
    font-size: 0.8rem;
}

.pg-pipe-head-actions .pg-link {
    background: none;
    border: none;
    padding: 0;
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.8rem;
    cursor: pointer;
}

.pg-pipe-head-actions .pg-link:hover {
    color: var(--primary-color);
}

.pg-pipe-head-actions .pg-link-danger:hover {
    color: #b91c1c;
}

.pg-row-unsupported .pg-row-name {
    cursor: default;
}

/* ---- sidebar row tools (pipelines): duplicate and delete on hover ---- */
.pg-row {
    position: relative;
}

.pg-row-tools {
    position: absolute;
    top: 0.3rem;
    right: 0.35rem;
    display: none;
    gap: 0.15rem;
}

.pg-row:hover .pg-row-tools,
.pg-row:focus-within .pg-row-tools {
    display: flex;
}

/* only rows that carry tools (the pipelines list) hide their count while hovered */
.pg-row:has(.pg-row-tools):hover .pg-model-size,
.pg-row:has(.pg-row-tools):focus-within .pg-model-size {
    visibility: hidden;
}

.pg-row-tool {
    width: 1.6rem;
    height: 1.6rem;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    background: var(--card-bg);
    color: var(--text-secondary);
    font-size: 0.7rem;
    cursor: pointer;
    display: grid;
    place-items: center;
}

.pg-row-tool:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.pg-row-tool-danger:hover {
    color: #b91c1c;
    border-color: #b91c1c;
}

/* ---- the sign-in prompt is always dismissable ---- */
.pg-dialog-signin {
    position: relative;
}

.pg-dialog-signin .pg-dialog-actions {   /* the sign-in options stacked, one full-width button each */
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
}

.pg-dialog-signin .pg-dialog-actions > * {
    justify-content: center;
    text-align: center;
}

.pg-dialog-close {
    position: absolute;
    top: 0.6rem;
    right: 0.6rem;
    width: 2rem;
    height: 2rem;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    display: grid;
    place-items: center;
}

.pg-dialog-close:hover {
    background: var(--surface-color);
    color: var(--text-primary);
}

/* ---- the links about the current thing, at the foot of the details table ---- */
.pg-details-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1.5rem;
    padding: 0.6rem 1rem;
    border-top: 1px solid var(--border-color);
    background: var(--surface-color);
    font-size: 0.85rem;
}

.pg-details-links a {
    color: var(--primary-color);
    text-decoration: none;
}

.pg-details-links a:hover {
    text-decoration: underline;
}

.pg-details-links i {
    width: 1.1rem;
}

/* ---- one Run button with the run-target switch above it ---- */
.pg-run-group {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.3rem;
}

.pg-target {
    display: inline-flex;
    padding: 2px;
    border: 1px solid var(--border-color);
    border-radius: 2px;
    background: var(--surface-color);
    font-size: 0.7rem;
}

.pg-target button {
    border: none;
    border-radius: 2px;
    padding: 0.12rem 0.6rem;
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
}

.pg-target button[aria-pressed="true"] {
    background: var(--primary-color);
    color: #fff;
}

.pg-target button:disabled {
    opacity: 0.4;
    cursor: default;
}

/* the ONNX tab: the file, then the lines that run it */
.pg-tabs > .pg-copy {
    margin-left: auto;
}

.pg-onnx-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem 1rem;
    padding: 0.85rem 1rem 0.25rem;
    background: var(--code-bg);
}

.pg-onnx-note {
    font-size: 0.78rem;
    color: #94a3b8;
}

.pg-btn.pg-btn-small {
    padding: 0.35rem 0.85rem;
    font-size: 0.82rem;
}

.pg-pane[hidden] {
    display: none;
}

/* a model's single threshold slider matches the operator sliders instead of spanning the panel */
.pg-model-panel .pg-param {
    grid-template-columns: 8.5rem minmax(0, 18rem) 4.5rem;
}

/* ---- pipelines: starter templates under the create box ---- */
.pg-pipe-templates {
    margin-top: 2rem;
}

.pg-pipe-templates h3 {
    margin: 0 0 0.75rem;
    font-size: 1rem;
    font-weight: 700;
}

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

@media (max-width: 760px) {
    .pg-pipe-template-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

.pg-pipe-template {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
    padding: 0.9rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    background: var(--card-bg);
    text-align: left;
    font: inherit;
    color: var(--text-primary);
    cursor: pointer;
}

.pg-pipe-template:hover {
    border-color: var(--primary-color);
}

.pg-pipe-template .pg-pipe-steps {
    margin: 0;
}

.pg-pipe-links {
    margin-top: 1.5rem;
}

/* the robot page keeps its links without the table */
.rb-links {
    margin-top: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 3px;
}


/* ---- point clouds ---- */
.pg-3d {
    margin: 1rem 0 0;
}

.pg-3d-canvas {
    display: block;
    width: 100%;
    height: 360px;
    border-radius: 3px;
    border: 1px solid var(--border-color);
    background: #0b1220;
    touch-action: none;
    cursor: grab;
}

.pg-3d figcaption {
    margin-top: 0.35rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
}

.rb-cloud {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 3px;
    border: 1px solid var(--border-color);
    background: #0b1220;
    touch-action: none;
    cursor: grab;
}

.rb-mini {
    margin-left: 0.3rem;
    padding: 0 0.4rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--card-bg);
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    vertical-align: middle;
}

.rb-mini[aria-pressed="true"] {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

/* ---- volume operators: two ray-marched views ---- */
.pg-vol-stage {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.pg-vol-stage figure {
    margin: 0;
}

.pg-vol-stage canvas {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 3px;
    border: 1px solid var(--border-color);
    background: #0b1220;
    touch-action: none;
    cursor: grab;
}

.pg-vol-stage figcaption {
    margin-top: 0.35rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    text-align: center;
}

.pg-thumb-volume {
    width: auto;
    min-width: 56px;
    height: 56px;
    padding: 0 0.7rem;
    display: grid;
    place-items: center;
    border: 2px solid transparent;
    border-radius: 3px;
    background: var(--surface-color);
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.78rem;
    cursor: pointer;
}

.pg-thumb-volume.pg-selected {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.pg-op-volume .pg-bar .pg-thumbs {   /* the samples and the colour-map picker share one row */
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1.25rem;
}

.pg-thumbs-pick.pg-thumbs-volumes {
    display: flex;
    flex-wrap: wrap;
    grid-template-columns: none;
}

.pg-vol-cmap {   /* the colour-map picker, level with the sample buttons */
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    align-self: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.pg-vol-cmap select {
    padding: 0.3rem 0.45rem;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    background: var(--background-color);
    color: var(--text-primary);
    font: inherit;
}

/* ---- the targeted export modal ---- */
.pg-export-grid {
    display: grid;
    gap: 0.7rem;
    margin: 0.75rem 0;
}

.pg-export-grid > label {
    display: grid;
    grid-template-columns: 8rem minmax(0, 1fr);
    align-items: center;
    gap: 0.75rem;
    font-size: 0.88rem;
}

.pg-export-grid > label > span:first-child {
    font-weight: 600;
    color: var(--text-primary);
}

.pg-export-grid select,
.pg-export-grid input[type="number"] {
    padding: 0.3rem 0.45rem;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    background: var(--background-color);
    color: var(--text-primary);
    font: inherit;
    font-size: 0.85rem;
}

.pg-export-grid input[type="number"] {
    width: 5rem;
}

.pg-export-shape {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}

.pg-export-choice,
.pg-export-params {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1rem;
}

.pg-export-choice label,
.pg-export-params label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.pg-export-fixed {
    color: var(--text-muted);
}

.pg-export-status {
    min-height: 1.2em;
    margin: 0.25rem 0 0.5rem;
    overflow-wrap: anywhere;
}

.pg-onnx-head .pg-btn-ghost.pg-btn-small {
    border-color: rgba(255, 255, 255, 0.25);
    background: transparent;
    color: #e2e8f0;
}

.pg-onnx-head .pg-btn-ghost.pg-btn-small:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.pg-export-shape input[type="number"] {
    width: 4.2rem;
}

/* the operator's full signature in the export modal */
.pg-export-sig {
    grid-column: 1 / -1;
    margin: -0.2rem 0 0.2rem;
}

.pg-export-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.pg-export-table th {
    text-align: left;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0.2rem 0.4rem;
    border-bottom: 1px solid var(--border-color);
}

.pg-export-table td {
    padding: 0.25rem 0.4rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.pg-export-table code {
    font-size: 0.82rem;
}

.pg-export-type {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.pg-export-value {
    width: 100%;
    padding: 0.28rem 0.45rem;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    background: var(--background-color);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.82rem;
}

.pg-export-sig .hub-item-meta {
    margin: 0.4rem 0 0;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.pg-dialog.pg-export {
    width: min(52rem, 94vw);
    max-width: 52rem;
}

/* the export report */
.pg-export-report {
    margin: 0.5rem 0 0.25rem;
    padding: 0.8rem 0.9rem;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    background: var(--surface-color);
    color: var(--text-secondary);
    font-size: 0.83rem;
    text-align: left;
}

.pg-export-report-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.pg-export-report-head strong {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-primary);
    overflow-wrap: anywhere;
}

.pg-export-report-table {
    width: 100%;
    border-collapse: collapse;
}

.pg-export-report-table th {
    width: 6.5rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    padding: 0.2rem 0.5rem 0.2rem 0;
    vertical-align: top;
    white-space: nowrap;
}

.pg-export-report-table td {
    padding: 0.2rem 0;
    overflow-wrap: anywhere;
}

.pg-export-report-code {
    margin: 0.6rem 0 0.4rem;
    padding: 0.6rem 0.75rem;
    border-radius: 3px;
    background: var(--code-bg);
    color: #e2e8f0;
    font-size: 0.78rem;
    line-height: 1.5;
    overflow-x: auto;
}

.pg-export-report .hub-item-meta {
    margin: 0;
    font-size: 0.76rem;
    color: var(--text-muted);
}

/* augmentations: the sample's mask, boxes and keypoints follow the same draw */
.pg-modalities {
    grid-template-columns: 8.5rem minmax(0, 1fr);
    margin-top: 0.35rem;
    padding-top: 0.6rem;
    border-top: 1px dashed var(--border-color);
}

.pg-modalities-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.pg-modalities .pg-modality {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    margin-right: 0.9rem;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    cursor: pointer;
}

.pg-modality::before {
    content: "";
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 2px;
    background: currentColor;
    opacity: 0.85;
}

.pg-modality-mask::before { background: #2563eb; }
.pg-modality-boxes::before { background: #f59e0b; }
.pg-modality-keypoints::before { background: #10b981; }

.pg-modality input:disabled + * ,
.pg-modality:has(input:disabled) {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ---- the pipeline graph editor ---- */
.pg-graph-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.pg-graph-bar .pg-select {
    max-width: 16rem;
}

.pg-graph-hint {
    margin-left: auto;
    font-size: 0.78rem;
}

.pg-graph {
    position: relative;
    min-height: 26rem;
    max-height: 40rem;
    overflow: auto;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    background:
        linear-gradient(var(--border-color) 1px, transparent 1px) 0 0 / 100% 24px,
        linear-gradient(90deg, var(--border-color) 1px, transparent 1px) 0 0 / 24px 100%,
        var(--surface-color);
    background-blend-mode: normal;
}

.pg-graph .pg-wires {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    overflow: visible;
}

.pg-graph .pg-wire {
    fill: none;
    stroke-width: 2.5;
    pointer-events: stroke;
    cursor: pointer;
    opacity: 0.9;
}

.pg-graph .pg-wire:hover {
    stroke-width: 4;
}

.pg-graph .pg-wire-temp {
    stroke-dasharray: 6 4;
    pointer-events: none;
}

.pg-nodes {
    position: relative;
    min-width: 100%;
    min-height: 100%;
}

.pg-node {
    position: absolute;
    width: 220px;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    background: var(--card-bg);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
    font-size: 0.82rem;
    user-select: none;
}

.pg-node-input { border-color: #93c5fd; }
.pg-node-output { border-color: #fca5a5; }
.pg-node-model { border-color: #c4b5fd; }

.pg-node-head {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.5rem 0.4rem 0.7rem;
    border-bottom: 1px solid var(--border-color);
    cursor: grab;
    border-radius: 3px 10px 0 0;
    background: var(--surface-color);
}

.pg-node-head:active {
    cursor: grabbing;
}

.pg-node-title {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1;
}

.pg-node-id {
    font-size: 0.68rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.pg-node-remove {
    border: 0;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 0.2rem;
    font-size: 0.85rem;
}

.pg-node-remove:hover {
    color: #b91c1c;
}

.pg-node-body {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 0.3rem;
    padding: 0.4rem 0;
    align-items: start;
}

.pg-ports {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding-top: 0.2rem;
}

.pg-port {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    cursor: crosshair;
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

.pg-ports-in .pg-port {
    margin-left: -7px;
}

.pg-ports-out .pg-port {
    margin-right: -7px;
    justify-content: flex-end;
}

.pg-port-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #94a3b8;
    background: var(--card-bg);
    flex: none;
    box-sizing: border-box;
}

.pg-port-optional .pg-port-dot {
    border-style: dashed;
}

.pg-port-ok .pg-port-dot {
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.25);
}

.pg-node-mid {
    min-width: 0;
    padding: 0 0.2rem;
}

.pg-node-params {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.pg-node-param {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.15rem;
    font-size: 0.72rem;
    color: var(--text-muted);
    cursor: default;
}

.pg-node-param span {
    font-family: var(--font-mono);
}

.pg-node-param input[type="range"] {
    width: 100%;
    margin: 0;
}

.pg-node-param output {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-align: right;
}

.pg-select-small,
.pg-input-small {
    font-size: 0.75rem;
    padding: 0.15rem 0.3rem;
    width: 100%;
    box-sizing: border-box;
}

.pg-graph-results {
    flex-wrap: wrap;
    justify-content: center;
}

.pg-graph-results figure {
    width: min(256px, 45vw);
}

@media (max-width: 720px) {
    .pg-graph-hint {
        display: none;
    }
}

/* pipelines: inputs left, outputs right, one panel per node */
.pg-io {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
}

.pg-io-block {
    border: 1px solid var(--border-color);
    border-radius: 3px;
    padding: 0.8rem 1rem 1rem;
    background: var(--card-bg);
    min-height: 8rem;
}

.pg-io-block h3 {
    margin: 0 0 0.75rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.pg-io-empty::after {
    content: "none yet: add a node in the graph above";
    font-size: 0.8rem;
    color: var(--text-muted);
}

.pg-io-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.pg-io-item {
    display: grid;
    grid-template-columns: minmax(0, 256px) auto;
    justify-content: start;
    gap: 0.6rem;
    align-items: start;
}

.pg-io-item figure,
.pg-io-outputs figure {
    margin: 0;
    max-width: 256px;
}

.pg-io-item canvas,
.pg-io-outputs canvas {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 3px;
    background: #000;
}

.pg-io-item figcaption,
.pg-io-outputs figcaption {
    margin-top: 0.3rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    text-align: center;
}

.pg-io-side {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-height: 256px;
    overflow-y: auto;
    padding-right: 2px;
}

.pg-io-side button {
    position: relative;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 3px;
    overflow: hidden;
    background: var(--surface-color);
    cursor: pointer;
    flex: none;
}

.pg-io-side button img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.pg-io-side button.pg-selected {
    border-color: var(--primary-color);
}

.pg-io-side .pg-thumb-play {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.8rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.pg-io-side .pg-thumb-upload {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

.pg-io-actions {
    justify-content: flex-start;
}

@media (max-width: 900px) {
    .pg-io {
        grid-template-columns: minmax(0, 1fr);
    }
}

.pg-graph-run {
    margin-left: 0.25rem;
}

.pg-io-item-mask canvas,
.pg-io-item-boxes canvas,
.pg-io-item-keypoints canvas {
    background: #f1f5f9;
}

.pg-io-side button canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.pg-row-name .pg-tag-pre {
    margin-left: auto;
}

/* the searchable node pickers on the graph toolbar */
.pg-picker {
    position: relative;
}

.pg-picker-panel {
    position: absolute;
    top: calc(100% + 0.35rem);
    left: 0;
    z-index: 30;
    width: 22rem;
    max-width: 90vw;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    background: var(--card-bg);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.15);
}

.pg-picker-panel .pg-input-small {
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
    padding: 0.35rem 0.5rem;
}

.pg-picker-list {
    max-height: 20rem;
    overflow-y: auto;
}

.pg-picker-group {
    padding: 0.4rem 0.4rem 0.15rem;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.pg-picker-item {
    display: flex;
    flex-direction: column;
    gap: 0.05rem;
    width: 100%;
    padding: 0.35rem 0.5rem;
    border: 0;
    border-radius: 3px;
    background: transparent;
    text-align: left;
    cursor: pointer;
    color: var(--text-primary);
    font: inherit;
}

.pg-picker-item strong {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    font-weight: 600;
}

.pg-picker-item .pg-note {
    font-size: 0.72rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pg-picker-item:hover,
.pg-picker-item:focus {
    background: var(--surface-color);
    outline: none;
}

.pg-pipe-note {
    width: 100%;
    box-sizing: border-box;
    margin: 0.35rem 0 0;
    font-size: 0.88rem;
    color: var(--text-secondary);
    border-color: transparent;
    background: transparent;
    padding-left: 0.2rem;
}

.pg-pipe-note:hover,
.pg-pipe-note:focus {
    border-color: var(--border-color);
    background: var(--card-bg);
}

.pg-pipe-import {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    align-items: flex-start;
}

.pg-row-import .pg-link {
    padding: 0.28rem 0.5rem;
    font-size: 0.8rem;
}

.rb-select {
    max-width: 100%;
    box-sizing: border-box;
}

/* the scene list is a <nav>: undo the site header's nav layout for it */
.pg-side nav.pg-side-list {
    display: block;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
}

/* phones: the sidebar collapses into tabs and one dropdown above the content */
.pg-side-mobile {
    display: none;
}

@media (max-width: 899px) {
    .pg-side {
        display: none;
    }

    .pg-side-mobile {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        margin: 0 0 1rem;
        order: -1;   /* first in the shell, whatever order the sidebar takes on phones */
    }

    .pg-side-mobile .pg-mode-mobile {
        width: 100%;
    }

    .pg-side-select {
        width: 100%;
        font-size: 0.95rem;
    }
}
