.pg {
    --pg-accent: #13d4e2;
    --pg-accent-dim: rgba(19, 212, 226, 0.14);
    --pg-panel: #171b1e;
    --pg-panel2: #1d2226;
    --pg-border: #2a3135;
    --pg-text: #e6eef0;
    --pg-muted: #7d8c92;
    --pg-ok: #3ccf7a;
    --pg-warn: #e6a23c;
    --pg-error: #e5534b;
    max-width: 1320px;
    margin: 0 auto;
    padding: 4px 16px 40px;
    box-sizing: border-box;
    color: var(--pg-text);
    font-family: 'Roboto Mono', monospace;
}

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

.pg-mono {
    font-family: 'Roboto Mono', monospace;
}

.pg-accent {
    color: var(--pg-accent);
}

.pg-dim {
    color: var(--pg-muted);
}

/* Hero */

.pg-hero {
    text-align: center;
    padding: 6px 0 22px;
}

.pg-hero-title {
    font-size: clamp(20px, 3.2vw, 32px);
    font-weight: 500;
    margin-bottom: 10px;
}

.pg-hero-text {
    color: var(--pg-muted);
    font-size: 14px;
    max-width: 760px;
    margin: 0 auto 18px;
    line-height: 1.6;
}

.pg-flow {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--pg-muted);
}

.pg-flow-node {
    border: 1px solid var(--pg-border);
    background: var(--pg-panel);
    border-radius: 6px;
    padding: 5px 10px;
    color: var(--pg-text);
}

.pg-flow-main {
    border-color: var(--pg-accent);
    color: var(--pg-accent);
    box-shadow: 0 0 16px rgba(19, 212, 226, 0.25);
}

.pg-flow-arrow {
    white-space: nowrap;
}

/* The steps: the key, send, code on the left; the live panel on the right */

.pg-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 440px);
    grid-template-areas:
        "key  live"
        "send live"
        "code live";
    grid-template-rows: auto auto 1fr;
    gap: 16px;
    align-items: start;
}

.pg-area-key { grid-area: key; }
.pg-area-send { grid-area: send; }
.pg-area-live { grid-area: live; position: sticky; top: 72px; }
.pg-area-code { grid-area: code; }

@media (max-width: 980px) {
    .pg-grid {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: "key" "send" "live" "code";
        grid-template-rows: none;
    }

    .pg-area-live {
        position: static;
    }
}

.pg-step {
    background: var(--pg-panel);
    border: 1px solid var(--pg-border);
    border-radius: 12px;
    padding: 16px;
    min-width: 0;
}

.pg-step-head {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 14px;
}

.pg-num {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1px solid var(--pg-accent);
    color: var(--pg-accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex: none;
}

.pg-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
    min-width: 0;
}

.pg-field-label {
    font-size: 12px;
    color: var(--pg-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.pg-tag {
    font-size: 10px;
    border-radius: 9px;
    padding: 1px 7px;
    border: 1px solid;
}

.pg-tag-secret {
    color: var(--pg-warn);
    border-color: rgba(230, 162, 60, 0.5);
}

.pg-tag-public {
    color: var(--pg-ok);
    border-color: rgba(60, 207, 122, 0.5);
}

.pg-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.pg-input,
.pg-value-box {
    height: 36px;
    border-radius: 6px;
    border: 1px solid var(--pg-border);
    background: #101315;
    color: var(--pg-text);
    font-size: 13px;
    padding: 0 10px;
    min-width: 0;
    flex: 1;
}

/* In a column (label above) a field keeps its height */
.pg-field > .pg-input {
    flex: none;
}

.pg-input:focus {
    outline: none;
    border-color: var(--pg-accent);
}

.pg-input.pg-invalid {
    border-color: var(--pg-error);
}

.pg-value-box {
    display: flex;
    align-items: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--pg-ok);
}

.pg-error {
    min-height: 0;
    font-size: 12px;
    color: var(--pg-error);
}

.pg-hint {
    font-size: 12px;
    color: var(--pg-muted);
    line-height: 1.55;
    margin-top: 4px;
}

.pg-btn {
    height: 36px;
    border-radius: 6px;
    border: 1px solid var(--pg-border);
    background: var(--pg-panel2);
    color: var(--pg-text);
    font: inherit;
    font-size: 13px;
    padding: 0 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    white-space: nowrap;
    flex: none;
    transition: border-color 0.12s, background 0.12s;
}

.pg-btn:hover {
    border-color: var(--pg-accent);
}

.pg-btn-primary {
    background: #0e5f66;
    border-color: #0e5f66;
}

.pg-btn-primary:hover {
    background: #12737b;
}

.pg-btn-ghost {
    background: none;
    color: var(--pg-accent);
}

.pg-icon-btn {
    width: 36px;
    padding: 0;
    font-size: 15px;
}

.pg-btn.pg-done {
    border-color: var(--pg-ok);
    color: var(--pg-ok);
}

.pg-links {
    flex-wrap: wrap;
    margin-top: 12px;
}

/* Send */

.pg-send {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto;
    gap: 10px;
    align-items: end;
}

.pg-send .pg-field {
    margin-bottom: 0;
}

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

    .pg-send-btn {
        grid-column: 1 / -1;
    }
}

.pg-slider-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 14px 0 10px;
}

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

.pg-auto {
    font-size: 13px;
    margin-bottom: 12px;
}

.pg-switch {
    position: relative;
    width: 38px;
    height: 22px;
    flex: none;
}

.pg-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.pg-switch span {
    position: absolute;
    inset: 0;
    border-radius: 11px;
    background: #2a3135;
    cursor: pointer;
    transition: background 0.15s;
}

.pg-switch span::before {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    top: 3px;
    border-radius: 50%;
    background: #cfd8dc;
    transition: transform 0.15s;
}

.pg-switch input:checked + span {
    background: #0e5f66;
}

.pg-switch input:checked + span::before {
    transform: translateX(16px);
    background: var(--pg-accent);
}

.pg-console {
    background: #0c0f11;
    border: 1px solid var(--pg-border);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 12px;
    height: 150px;
    overflow-y: auto;
    line-height: 1.6;
}

.pg-console-empty {
    color: var(--pg-muted);
}

.pg-console-line {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pg-console-time {
    color: #4f5d63;
    margin-right: 8px;
}

.pg-req {
    color: #9fb3ba;
}

.pg-res-ok {
    color: var(--pg-ok);
}

.pg-res-err {
    color: var(--pg-error);
}

/* Live */

.pg-live {
    border-color: rgba(19, 212, 226, 0.35);
    box-shadow: 0 0 0 1px rgba(19, 212, 226, 0.05), 0 12px 40px rgba(0, 0, 0, 0.35);
}

.pg-live-head {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.pg-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--pg-error);
    box-shadow: 0 0 8px var(--pg-error);
    animation: pg-pulse 1.4s infinite;
    flex: none;
}

@keyframes pg-pulse {
    50% {
        opacity: 0.35;
    }
}

.pg-live-label {
    color: var(--pg-error);
    letter-spacing: 1px;
}

.pg-live-item {
    color: var(--pg-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.pg-live-age {
    margin-left: auto;
    color: var(--pg-muted);
    white-space: nowrap;
}

.pg-live-value {
    font-size: clamp(34px, 5vw, 52px);
    color: var(--pg-accent);
    text-shadow: 0 0 24px rgba(19, 212, 226, 0.35);
    margin: 6px 0 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color 0.4s;
}

.pg-live-value.pg-flash {
    color: #ffffff;
    transition: none;
}

.pg-chart {
    display: block;
    width: 100%;
    height: 170px;
    background: #101315;
    border-radius: 8px;
}

.pg-chart-caption {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--pg-muted);
    margin: 6px 0 14px;
}

.pg-windows {
    display: flex;
    gap: 4px;
}

.pg-win {
    background: none;
    border: 1px solid var(--pg-border);
    border-radius: 5px;
    color: var(--pg-muted);
    font: inherit;
    font-size: 11px;
    padding: 2px 8px;
    cursor: pointer;
}

.pg-win:hover {
    color: var(--pg-text);
}

.pg-win.pg-active {
    color: var(--pg-accent);
    border-color: rgba(19, 212, 226, 0.5);
    background: var(--pg-accent-dim);
}

.pg-json-head {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 12px;
    margin-bottom: 6px;
}

.pg-json {
    margin: 0;
    background: #0c0f11;
    border: 1px solid var(--pg-border);
    border-radius: 8px;
    padding: 10px;
    font-size: 11px;
    line-height: 1.5;
    max-height: 260px;
    overflow: auto;
    color: #b8c7cc;
}

.pg-json .k { color: #7fb4ff; }
.pg-json .s { color: #a5d6a7; }
.pg-json .n { color: var(--pg-accent); }

/* Code */

.pg-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 8px;
}

.pg-tab {
    background: none;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--pg-muted);
    font: inherit;
    font-size: 12px;
    padding: 6px 10px;
    cursor: pointer;
}

.pg-tab:hover {
    color: var(--pg-text);
}

.pg-tab.pg-active {
    color: var(--pg-accent);
    border-color: rgba(19, 212, 226, 0.4);
    background: var(--pg-accent-dim);
}

.pg-code-box {
    position: relative;
}

.pg-code {
    margin: 0;
    background: #0c0f11;
    border: 1px solid var(--pg-border);
    border-radius: 8px;
    padding: 14px;
    padding-right: 80px;
    font-size: 12px;
    line-height: 1.6;
    overflow-x: auto;
    color: #d5e1e5;
    white-space: pre;
}

.pg-code .c { color: #5f7178; }
.pg-code .s { color: #a5d6a7; }
.pg-code .kw { color: #c792ea; }

.pg-copy-code {
    position: absolute;
    top: 8px;
    right: 8px;
    height: 28px;
    font-size: 12px;
    padding: 0 10px;
}

/* Concepts */

.pg-concepts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin-top: 28px;
}

.pg-concept {
    border: 1px solid var(--pg-border);
    border-radius: 10px;
    padding: 14px;
    font-size: 12px;
    color: var(--pg-muted);
    line-height: 1.6;
}

.pg-concept-title {
    color: var(--pg-text);
    font-size: 14px;
    margin-bottom: 6px;
}

.pg-next {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 24px;
}
