/* ── POP Canvas — specific styles (layered on top of canvas.css) ──────────── */

:root:not([data-theme="hike"]) {
    --pop-accent:  #fbbf24;
    --pop-accent2: #d97706;
    --pop-conn:    rgba(251, 191, 36, 0.65);
    --pop-glow:    rgba(251, 191, 36, 0.4);
}

[data-theme="hike"] {
    --pop-accent:  #C09B3E;
    --pop-accent2: #8B6914;
    --pop-conn:    rgba(139, 105, 20, 0.45);
    --pop-glow:    rgba(139, 105, 20, 0.2);
}

/* ── Toolbar ────────────────────────────────────────────────── */
#popToolbar {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .5rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
    background: rgba(7, 7, 13, 0.6);
}

.pop-source-name {
    font-size: .72rem;
    color: var(--text-dim);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 6px;
    padding: .2rem .6rem;
    background: rgba(255,255,255,0.03);
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pop-source-name.loaded {
    color: #fbbf24;
    border-color: rgba(251,191,36,0.25);
    background: rgba(251,191,36,0.06);
}

/* ── Workspace ──────────────────────────────────────────────── */
#popWorkspace {
    flex: 1;
    overflow: hidden;
    position: relative;
    cursor: default;
}

#popWorld {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
    width: 5000px;
    height: 5000px;
}

#popSvgLayer {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    overflow: visible;
    pointer-events: none;
}

/* ── Bubbles (same as canvas, different hue via CSS vars) ─── */
#popBubblesLayer {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

/* ── Empty state ────────────────────────────────────────────── */
#popEmpty {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
    opacity: .4;
}

#popEmpty.has-btn {
    pointer-events: auto;
}

.pop-empty-icon {
    font-size: 2.8rem;
    margin-bottom: .5rem;
    opacity: .6;
}

#popEmpty h3 {
    font-size: 1.1rem;
    margin-bottom: .4rem;
    font-weight: 500;
}

#popEmpty p {
    font-size: .8rem;
    color: var(--text-dim);
}

/* ── Format-picker menu (floating panel) ─────────────────────── */
.pop-format-menu {
    position: absolute;
    top: 92px;   /* below toolbar */
    left: 16px;
    z-index: 300;
    background: #0f0f1a;
    border: 1px solid rgba(255,255,255,0.09);
    border-radius: 14px;
    width: 340px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    padding: 0;
    animation: popMenuIn .18s ease;
}

.pop-format-menu.hidden { display: none; }

@keyframes popMenuIn {
    from { opacity: 0; transform: translateY(-6px) scale(.97); }
    to   { opacity: 1; transform: none; }
}

.pfm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .7rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    font-size: .78rem;
    font-weight: 600;
    color: var(--text);
}

.pfm-close {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: .8rem;
    padding: .2rem .4rem;
    border-radius: 4px;
    transition: .15s;
}
.pfm-close:hover { color: var(--text); background: rgba(255,255,255,0.06); }

.pfm-section-label {
    font-size: .63rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-dim);
    padding: .65rem 1rem .2rem;
}

.pfm-grid {
    padding: .3rem .5rem .7rem;
}

.pfm-item {
    display: flex;
    align-items: center;
    gap: .6rem;
    width: 100%;
    background: none;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: .45rem .6rem;
    cursor: pointer;
    transition: .15s;
    color: var(--text);
    font-family: inherit;
    font-size: .78rem;
    text-align: left;
}

.pfm-item:hover {
    background: rgba(251,191,36,0.07);
    border-color: rgba(251,191,36,0.2);
}

.pfm-item.selected {
    background: rgba(251,191,36,0.1);
    border-color: rgba(251,191,36,0.35);
    color: #fbbf24;
}

.pfm-icon {
    flex-shrink: 0;
    border: 1.5px solid rgba(255,255,255,0.15);
    border-radius: 3px;
    background: rgba(255,255,255,0.04);
}
.pfm-sq     { width: 22px; height: 22px; }
.pfm-story  { width: 13px; height: 22px; }
.pfm-banner { width: 32px; height: 17px; }
.pfm-wide   { width: 28px; height: 15px; }
.pfm-a4p    { width: 15px; height: 21px; }
.pfm-a4l    { width: 21px; height: 15px; }
.pfm-a3p    { width: 15px; height: 21px; }
.pfm-poster { width: 14px; height: 20px; }
.pfm-rollup { width: 10px; height: 22px; }

.pfm-name {
    flex: 1;
    font-size: .78rem;
}

.pfm-size {
    font-size: .65rem;
    color: var(--text-dim);
    font-weight: 400;
}

.pfm-custom {
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .4rem .1rem;
    flex-wrap: wrap;
}

.pfm-custom input[type="number"],
.pfm-custom input[type="text"] {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 7px;
    color: var(--text);
    font-family: inherit;
    font-size: .72rem;
    padding: .28rem .45rem;
    outline: none;
}

.pfm-custom input[type="number"] { width: 70px; }
.pfm-custom input[type="text"]   { width: 90px; }
.pfm-custom input:focus { border-color: rgba(251,191,36,0.4); }
.pfm-custom span { color: var(--text-dim); font-size: .8rem; }

/* ── POP Nodes ──────────────────────────────────────────────── */

/* Source node */
.pop-node {
    position: absolute;
    background: var(--node-bg);
    border: 1.5px solid var(--node-border);
    border-radius: var(--radius);
    cursor: grab;
    user-select: none;
    transition: border-color .2s, box-shadow .2s;
}

.pop-node:hover {
    border-color: rgba(251,191,36,0.35);
}

.pop-node.selected {
    border-color: var(--pop-accent);
    box-shadow: 0 0 0 1px rgba(251,191,36,0.3), 0 0 24px rgba(251,191,36,0.18);
}

.pop-node.dragging {
    cursor: grabbing;
    box-shadow: 0 12px 40px rgba(0,0,0,0.6);
    z-index: 200;
}

/* Source node width */
.pop-node-source { width: 220px; }

/* Format node width */
.pop-node-format { width: 240px; }

/* Result node */
.pop-node-result { width: 260px; }

.pop-node-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .45rem .65rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.pop-node-type {
    font-size: .65rem;
    color: var(--text-dim);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: .3rem;
}

.pop-node-del {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: .8rem;
    padding: .1rem .3rem;
    border-radius: 4px;
    opacity: 0;
    transition: .15s;
}

.pop-node:hover .pop-node-del { opacity: 1; }
.pop-node-del:hover { color: #f87171; background: rgba(248,113,113,0.1); }

/* Source body — SVG preview */
.pop-source-body {
    padding: 0;
    position: relative;
}

.pop-svg-preview {
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: rgba(255,255,255,0.02);
    position: relative;
}

.pop-svg-preview svg {
    max-width: 100%;
    max-height: 100%;
    pointer-events: none;
}

.pop-svg-placeholder {
    font-size: 2rem;
    opacity: .3;
}

.pop-source-info {
    padding: .3rem .65rem;
    font-size: .62rem;
    color: var(--text-dim);
    border-top: 1px solid rgba(255,255,255,0.04);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Format body */
.pop-format-body {
    padding: .6rem .65rem;
    display: flex;
    flex-direction: column;
    gap: .45rem;
}

.pop-format-dims {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .72rem;
    color: var(--text);
    font-weight: 500;
}

.pop-format-badge {
    font-size: .6rem;
    padding: .15rem .4rem;
    border-radius: 4px;
    font-weight: 600;
    background: rgba(56,189,248,0.1);
    color: #38bdf8;
    border: 1px solid rgba(56,189,248,0.2);
}

.pop-format-badge.print {
    background: rgba(251,191,36,0.1);
    color: #fbbf24;
    border-color: rgba(251,191,36,0.25);
}

.pop-format-instructions {
    width: 100%;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    padding: .4rem .5rem;
    color: var(--text);
    font-family: inherit;
    font-size: .7rem;
    resize: none;
    height: 52px;
    outline: none;
    transition: border-color .15s;
}
.pop-format-instructions:focus {
    border-color: rgba(251,191,36,0.35);
}
.pop-format-instructions::placeholder { color: rgba(255,255,255,0.2); }

.pop-format-foot {
    display: flex;
    gap: .35rem;
}

.pop-run-btn {
    flex: 1;
    background: rgba(251,191,36,0.1);
    border: 1px solid rgba(251,191,36,0.25);
    color: #fbbf24;
    border-radius: 7px;
    padding: .3rem;
    font-size: .7rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: .15s;
}

.pop-run-btn:hover {
    background: rgba(251,191,36,0.18);
    box-shadow: 0 0 12px rgba(251,191,36,0.15);
}

.pop-run-btn:disabled {
    opacity: .4;
    cursor: default;
}

/* Connection handle (POP variant — amber) */
.pop-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #fbbf24;
    border: 2px solid var(--bg);
    border-radius: 50%;
    opacity: 0;
    transition: opacity .15s, transform .15s;
    z-index: 10;
}

.pop-node:hover .pop-handle,
.pop-handle:hover { opacity: 1; }
.pop-handle:hover { transform: scale(1.4); }

.pop-handle-r { right: -7px; top: 50%; margin-top: -6px; cursor: crosshair; }
.pop-handle-l { left: -7px; top: 50%; margin-top: -6px; cursor: crosshair; }

/* SVG connections (amber) */
.pop-path {
    fill: none;
    stroke: var(--pop-conn);
    stroke-width: 1.5;
    stroke-dasharray: 6 4;
    stroke-linecap: round;
    pointer-events: none;
}

/* Result node */
.pop-result-body {
    padding: 0;
}

.pop-result-preview {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.02);
    overflow: hidden;
    min-height: 80px;
    position: relative;
}

.pop-result-preview svg {
    max-width: 100%;
    pointer-events: none;
}

.pop-result-dims {
    font-size: .62rem;
    color: var(--text-dim);
    padding: .25rem .65rem;
    border-top: 1px solid rgba(255,255,255,0.04);
}

.pop-result-actions {
    display: flex;
    gap: .3rem;
    padding: .35rem .5rem;
    border-top: 1px solid rgba(251,191,36,0.08);
}

.pop-result-btn {
    flex: 1;
    background: rgba(251,191,36,0.07);
    border: 1px solid rgba(251,191,36,0.15);
    color: #fbbf24;
    border-radius: 6px;
    padding: .28rem .3rem;
    font-size: .65rem;
    font-weight: 500;
    cursor: pointer;
    transition: .15s;
    font-family: inherit;
}
.pop-result-btn:hover { background: rgba(251,191,36,0.15); }

/* Generation overlay on format node */
.pop-gen-overlay {
    position: absolute;
    inset: 0;
    border-radius: calc(var(--radius) - 1.5px);
    background: rgba(7,7,13,0.88);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    z-index: 50;
    backdrop-filter: blur(4px);
}

.pop-gen-label {
    font-size: .7rem;
    color: #fbbf24;
    font-weight: 500;
}

.pop-prog-wrap {
    width: 80%;
    height: 3px;
    background: rgba(255,255,255,0.08);
    border-radius: 99px;
    overflow: hidden;
}

.pop-prog-fill {
    height: 100%;
    background: linear-gradient(90deg, #fbbf24, #f59e0b);
    border-radius: 99px;
    transition: width .3s ease;
    width: 0%;
}

.pop-prog-pct {
    font-size: .62rem;
    color: var(--text-dim);
}

/* ── Preview modal (POP variant) ────────────────────────────── */
#popPreviewModal {
    position: fixed;
    inset: 0;
    z-index: 900;
    background: rgba(0,0,0,0.88);
    backdrop-filter: blur(10px);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    cursor: zoom-out;
}

#popPreviewModal.open { display: flex; }

.pop-preview-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .75rem;
    cursor: default;
}

#popPmImg {
    max-width: min(88vw, 900px);
    max-height: 80vh;
    border-radius: 10px;
    box-shadow: 0 24px 80px rgba(0,0,0,0.6);
    object-fit: contain;
}

.pop-preview-dl {
    background: rgba(251,191,36,0.12);
    border: 1px solid rgba(251,191,36,0.3);
    color: #fbbf24;
    border-radius: 8px;
    padding: .4rem 1rem;
    font-size: .8rem;
    font-weight: 500;
    text-decoration: none;
    transition: .15s;
    font-family: 'Inter', sans-serif;
}

.pop-preview-dl:hover {
    background: rgba(251,191,36,0.2);
}

#popPreviewModal .pm-close {
    position: absolute;
    top: 1.2rem;
    right: 1.4rem;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    color: var(--text);
    border-radius: 8px;
    padding: .3rem .65rem;
    font-size: .8rem;
    cursor: pointer;
}

/* ── Viewport pan controls ─────────────────────────────────── */
#popViewControls {
    position: absolute;
    bottom: 1.2rem;
    right: 1.4rem;
    display: flex;
    gap: .35rem;
    z-index: 50;
}

.pop-vc-btn {
    background: rgba(7,7,13,0.85);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-dim);
    border-radius: 8px;
    padding: .3rem .6rem;
    font-size: .7rem;
    cursor: pointer;
    font-family: inherit;
    transition: .15s;
    backdrop-filter: blur(6px);
}
.pop-vc-btn:hover { color: var(--text); border-color: rgba(255,255,255,0.2); }

/* ── Sparkles (Brillitos) ──────────────────────────────────── */
.sparkle-container {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
    overflow: hidden;
}

.sparkle {
    position: absolute;
    background: #fff;
    border-radius: 50%;
    opacity: 0;
    pointer-events: none;
    box-shadow: 0 0 8px 1px #fff, 0 0 16px 2px var(--pop-accent);
    animation: sparkle-float var(--dur) ease-in-out infinite;
    animation-delay: var(--delay);
}

@keyframes sparkle-float {
    0%, 100% { 
        transform: translate(0, 0) scale(0);
        opacity: 0;
    }
    50% { 
        transform: translate(var(--tx), var(--ty)) scale(var(--scale));
        opacity: 0.7;
    }
}

.sparkle-star {
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

/* ══════════════════════════════════════════════════════════════════════════════
   HIKE THEME OVERRIDES — pop.css
   ══════════════════════════════════════════════════════════════════════════════ */

[data-theme="hike"] .pop-source-name {
    border-color: rgba(0, 0, 0, 0.09);
    background: rgba(0, 0, 0, 0.02);
    color: var(--text-dim);
}

[data-theme="hike"] .pop-source-name.loaded {
    color: var(--hike-accent-dark);
    border-color: rgba(139, 105, 20, 0.2);
    background: rgba(139, 105, 20, 0.04);
}

[data-theme="hike"] .pop-format-menu {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.09);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.10), 0 4px 12px rgba(0, 0, 0, 0.05);
}

[data-theme="hike"] .pfm-header {
    border-bottom-color: rgba(0, 0, 0, 0.06);
    color: var(--text);
}

[data-theme="hike"] .pfm-close {
    color: var(--text-dim);
}

[data-theme="hike"] .pfm-close:hover {
    color: var(--text);
    background: rgba(0, 0, 0, 0.04);
}

[data-theme="hike"] .pfm-item {
    color: var(--text);
}

[data-theme="hike"] .pfm-item:hover {
    background: rgba(139, 105, 20, 0.04);
    border-color: rgba(139, 105, 20, 0.15);
}

[data-theme="hike"] .pfm-item.selected {
    background: rgba(139, 105, 20, 0.06);
    border-color: rgba(139, 105, 20, 0.3);
    color: var(--hike-accent-gold);
}

[data-theme="hike"] .pfm-icon {
    border-color: rgba(0, 0, 0, 0.15);
    background: rgba(0, 0, 0, 0.04);
}

[data-theme="hike"] .pfm-custom input {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.1);
    color: var(--text);
}

[data-theme="hike"] .pfm-custom input:focus {
    border-color: var(--hike-accent-gold);
}

[data-theme="hike"] .pop-svg-preview,
[data-theme="hike"] .pop-result-preview {
    background: rgba(0, 0, 0, 0.02);
}

[data-theme="hike"] .pop-source-info,
[data-theme="hike"] .pop-result-dims {
    border-top-color: rgba(0, 0, 0, 0.06);
}

[data-theme="hike"] .pop-format-instructions {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.1);
    color: var(--text);
}

[data-theme="hike"] .pop-format-instructions:focus {
    border-color: rgba(139, 105, 20, 0.35);
}

[data-theme="hike"] .pop-run-btn {
    background: var(--hike-accent-dark);
    border-color: var(--hike-accent-dark);
    color: #FFFFFF;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

[data-theme="hike"] .pop-run-btn:hover:not(:disabled) {
    background: var(--hike-accent-deep);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    transform: translateY(-1px);
}

[data-theme="hike"] .pop-result-actions {
    border-top-color: rgba(0, 0, 0, 0.06);
}

[data-theme="hike"] .pop-result-btn {
    background: #FFFFFF;
    border-color: rgba(0, 0, 0, 0.09);
    color: #3F3F46;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

[data-theme="hike"] .pop-result-btn:hover {
    background: #F5F4F1;
    border-color: rgba(0, 0, 0, 0.18);
}

[data-theme="hike"] .pop-gen-overlay {
    background: rgba(252, 249, 247, 0.9);
}

[data-theme="hike"] .pop-gen-label {
    color: var(--hike-accent-dark);
}

[data-theme="hike"] .pop-prog-wrap {
    background: rgba(0, 0, 0, 0.08);
}

[data-theme="hike"] .pop-prog-fill {
    background: linear-gradient(90deg, #C09B3E, #8B6914);
}

[data-theme="hike"] #popPreviewModal {
    background: rgba(252, 249, 247, 0.92);
}

[data-theme="hike"] .pop-preview-dl {
    background: var(--hike-accent-dark);
    border-color: var(--hike-accent-deep);
    color: #fff;
}

[data-theme="hike"] .pop-preview-dl:hover {
    background: var(--hike-accent-deep);
}

[data-theme="hike"] #popPreviewModal .pm-close {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.1);
    color: var(--text);
}

[data-theme="hike"] .pop-vc-btn {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.1);
    color: var(--text-dim);
}

[data-theme="hike"] .pop-vc-btn:hover {
    color: var(--text);
    border-color: var(--hike-accent-dark);
}

[data-theme="hike"] .sparkle {
    background: var(--hike-accent-gold);
    box-shadow: 0 0 8px 1px rgba(139,105,20,0.4), 0 0 16px 2px rgba(139,105,20,0.2);
}




/* TEST MODE badge */
.test-badge {
    display: inline-block; font-size: 0.5rem; font-weight: 800; letter-spacing: 0.15em; text-transform: uppercase;
    padding: 1px 5px; border-radius: 4px; background: rgba(244,235,51,0.15); color: #F4EB33;
    border: 1px solid rgba(244,235,51,0.3); margin-left: 2px; vertical-align: middle;
}
[data-theme="hike"] .test-badge { background: rgba(139,105,20,0.08); color: #8B6914; border-color: rgba(139,105,20,0.2); }
