* {
    box-sizing: border-box
}

:root {
    --bg: #0f172a;
    --panel: #111827;
    --muted: #334155;
    --text: #e5e7eb;
    --accent: #60a5fa;
    --accent2: #22c55e;
    --danger: #ef4444
}

html, body {
    height: 100%
}

body {
    margin: 0;
    font-family: system-ui;
    background: var(--bg);
    color: var(--text)
}

.app-header {
    padding: 7px 14px;
    border-bottom: 1px solid #1f2937;
    background: #0b1220;
    display: grid;
    grid-template-columns:1fr 32px;
    align-items: center;
    align-content: center;

    h1{
        margin: 0;
        font-size: 20px
    }
    a{
        width: 32px;
        height: 32px;
        display: block;
        align-items: center;
        svg{
            width: 100%;
            height: 100%;
        }
    }
}


.btn {
    display: inline-block;
    background: var(--accent);
    color: #0b1220;
    text-decoration: none;
    border: none;
    border-radius: 8px;
    padding: 10px 14px;
    font-weight: 600;
    cursor: pointer
}

.btn.secondary {
    background: #374151;
    color: #e5e7eb
}

.btn.danger {
    background: var(--danger);
    color: #fff
}

.btn.trash_icon {
    background: none
}

.btn.small {
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px
}

input, select, button {
    font: inherit
}

input, select {
    background: #0b1220;
    border: 1px solid #1f2937;
    color: var(--text);
    padding: 8px 10px;
    border-radius: 8px
}

label {
    display: inline-block;
    margin-bottom: 6px;
    color: #cbd5e1
}

main.home {
    display: grid;
    grid-template-columns:1fr;
    gap: 24px;
    max-width: 960px;
    margin: 24px auto;
    padding: 0 16px
}

.inline-form {
    display: flex;
    gap: 8px;
    align-items: flex-end
}

/* Builder layout */
.builder {
    display: flex;
    height: calc(100vh - 64px)
}

.sidebar {
    width: 30%;
    min-width: 260px;
    max-width: 520px;
    border-right: 1px solid #1f2937;
    display: flex;
    flex-direction: column;
    overflow: hidden
}

.main {
    width: 70%;
    flex: 1;
    display: flex;
    flex-direction: column
}

.sidebar .top {
    padding: 12px;
    border-bottom: 1px solid #1f2937
}

.sidebar .scroll {
    flex: 1;
    overflow: auto;
    padding: 8px
}

.scene-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px
}

.scene-item {
    display: grid;
    grid-template-columns:auto 80px 1fr auto;
    gap: 8px;
    align-items: center;
    background: #0b1220;
    border: 1px solid #1f2937;
    border-radius: 8px;
    padding: 6px
}

.scene-item[aria-selected="true"] {
    outline: 2px solid var(--accent)
}

.drag-handle {
    cursor: grab;
    padding: 0 6px;
    color: #94a3b8
}

.scene-thumb {
    width: 80px;
    height: 50px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #1f2937
}

.scene-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis
}

.scene-actions button {
    margin-left: 6px
}

.add-row {
    padding: 8px;
    border-top: 1px solid #1f2937;
    display: flex;
    gap: 8px
}

.viewer-wrap {
    position: relative;
    flex: 1
}

#viewer {
    position: absolute;
    inset: 0
}

.viewer-controls {
    position: absolute;
    left: 10px;
    bottom: 10px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap
}

.link-tools {
    display: flex;
    gap: 8px
}

/* Hotspot custom UI */
/* Label above, circular arrow marker centered, actions centered below (on hover) */
.pnlm-hotspot-base .hotspot-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    pointer-events: auto
}

.pnlm-hotspot-base .hotspot-label {
    background: rgba(15, 23, 42, .85);
    border: 1px solid #1f2937;
    color: #e5e7eb;
    padding: 4px 6px;
    border-radius: 6px;
    font-size: 12px;
    display: inline-block;
    text-align: center;
    text-wrap: nowrap;
}

.pnlm-hotspot-base .hotspot-pin {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #0b1220;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .35);
    transition: transform .12s ease, background .12s ease
}

.pnlm-hotspot-base .hotspot-pin .arrow {
    color: #0b1220;
    font-size: 20px;
    line-height: 1;
    transform: none

    /*img {*/
    /*    box-shadow: 0 0 15px rgba(0,0,0,0.6); !* x-offset, y-offset, blur, color *!*/
    /*    border-radius: 50%;*/
    /*}*/
}

.pnlm-hotspot-base:hover .hotspot-pin {
    transform: scale(1.08)
}

.pnlm-hotspot-base .hotspot-actions {
    display: flex;
    gap: 6px;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s ease
}

.pnlm-hotspot-base:hover .hotspot-actions {
    opacity: 1;
    pointer-events: auto
}

.pnlm-hotspot-base .hotspot-actions button {
    background: #1f2937;
    color: #e5e7eb;
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 3px 6px;
    font-size: 11px
}

/* Target picker overlay */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .6);
    display: none;
    align-items: center;
    justify-content: center
}

.overlay .panel {
    background: #0b1220;
    border: 1px solid #1f2937;
    border-radius: 10px;
    padding: 12px;
    max-width: 900px;
    width: min(90vw, 900px);
    max-height: 80vh;
    overflow: auto;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

#targetPickerList {
    display: grid;
    grid-template-columns:repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;

}

.overlay-item {
    border: 1px solid #1f2937;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    background: #0b1220;

    &.selected {
        border: 2px solid #f39c12; /* bright orange border */
        background-color: rgba(255, 165, 0, 0.1); /* subtle highlight */
    }
}

.overlay-item img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    display: block
}

.overlay-item .label {
    padding: 6px 8px;
    font-size: 12px
}

.overlay .actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px
}

.overlay-item.highlighted {

}

/* Finish row */
#tourLinkRow {
    display: none;
    padding: 10px;
    border-top: 1px solid #1f2937;
    background: #0b1220
}

#tourLinkRow a {
    color: var(--accent)
}

/* Viewer page */
.viewer-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100%;

}

.viewer-toolbar {
    position: fixed;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 10px;

    .btn {
        background: #fff;
    }
}

.viewer-stage {
    position: relative;
    flex: 1;
    height: 100%;
    width: 100%;
}

#vviewer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.play-indicator {
    position: fixed;
    left: 50%;
    bottom: 80px;
    transform: translateX(-50%);
    background: #0b1220;
    border: 1px solid #1f2937;
    border-radius: 8px;
    padding: 6px 8px;
}

/* Responsive */
@media (max-width: 900px) {
    .builder {
        flex-direction: column
    }

    .sidebar {
        width: 100%;
        max-width: none;
        min-height: 200px
    }

    .main {
        width: 100%;
        min-height: 50vh
    }
}

@media (max-width: 600px) {
    main.home {
        grid-template-columns:1fr
    }

    .viewer-controls {
        left: 8px;
        right: 8px;
        justify-content: center
    }
}

@media (max-width: 768px) {
    .viewer-toolbar {
        left: 0;
        right: 0;
        bottom: 10px;
        justify-content: center;
        flex-wrap: wrap;
        border-radius: 8px;
    }

    .play-indicator {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        bottom: 60px;
        text-align: center;
        margin-bottom: 10px;
    }
}

#playIndicator {
    display: none;
}

/* Indicator for scenes without links */
.scene-actions .link-indicator {
    margin-right: 6px;
    color: var(--danger);
    font-weight: 700;
    font-size: 12px;
}
