html, body {
    /* background-color: rgb(42, 37, 48); */
    height: 100%;
    margin: 0;
    overflow: hidden;

    /* dark fade at bottom */
    background:
        
        linear-gradient(
            to bottom,
            rgba(0, 0, 0, 0) 20%,
            rgba(0, 0, 0, 0.55) 100%
        );
    /* background-color: rgba(71, 41, 86, 1); */
    background-color: rgb(66, 47, 77);
}

* {
    font-family: "Google Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Waves image in top-left corner only; fades out into purple + dark gradient */
#backgroundImgLayer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

#logoBackgroundImg {
    position: absolute;
    left: 0;
    top: 0;
    min-width: 700px;
    width: 65vw;
    height: 65vh;
    min-height: 400px;
    object-fit: cover;
    object-position: top left;
    opacity: 0.15;
    pointer-events: none;
    /* Visible on 2/5 of page from top-left; faster but smooth transition into purple/dark gradient */
    mask-image: radial-gradient(ellipse 100% 100% at 0% 0%, black 0%, black 58%, transparent 78%);
    -webkit-mask-image: radial-gradient(ellipse 100% 100% at 0% 0%, black 0%, black 58%, transparent 78%);
    mask-size: cover;
    mask-position: top left;
    -webkit-mask-size: cover;
    -webkit-mask-position: top left;
}

#textlogoImmage {
    min-width: 100px;
    width: 6%;
    height: auto;
}

/* #bg-layer {
    position: fixed;
    inset: 0;
    background-image: url("your-image.png");
    background-repeat: no-repeat;
    background-position: top left;
    pointer-events: none;
    z-index: -1;
} */

h1 {
    color: rgb(255, 255, 255);
    font-family: Verdana, Geneva, Tahoma, sans-serif;
    letter-spacing: -2px;
    margin:5px 5px ;
}

#elements {
    position: relative;
    z-index: 1;
    display: grid;
    height: 96%;
    width: 100%;
    grid-template-columns: 1fr;
    grid-template-rows: 50px 45px 1fr;
    grid-gap: 3px;
    padding: 10px;
    box-sizing: border-box;
}

#ribbon {
    /* border: 2px solid rgb(0, 255, 21); */
    padding: 0 0;
    display: flex;
    box-sizing: border-box;
}

/* nav {
    height: 30px;
    width: 350px;
    position: relative;
    top: 13px;
    left: 40px;
    border: 2px solid rgb(0, 247, 255);

} */

.searchContainer {
    position: relative; /* Essential for positioning the icon inside */
    display: inline-flex;
    align-items: center;
}

/* Wrapper for search bar icon layers – crossfade between search and info icon */
.searchBarWrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    overflow: visible;
}

.searchBarWrapper::before,
.searchBarWrapper::after {
    content: '';
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 22px;           /* taller so icon isn’t clipped top/bottom */
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;      /* show full icon without clipping */
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.searchBarWrapper::before {
    background-image: url("media2/search icon.png");
    opacity: 1;
}

.searchBarWrapper::after {
    background-image: url("media2/info icon 2.png"); /* Add your info icon file here */
    opacity: 0;
}

.searchBarWrapper.searchBarShowingInfo::before {
    opacity: 0;
}

.searchBarWrapper.searchBarShowingInfo::after {
    opacity: 1;
}

#infoBox {
    background-color: rgba(42, 37, 48, 0.75);
    padding-left: 32px;           /* icon width + spacing */
    width: 350px;
    height: 30px;
    line-height: 26px;
    border: 1px solid rgba(42, 37, 48, 0.75);
    box-sizing: border-box;
    color: white;
    border-radius: 2px; 
    transition: background-color 0.1s ease-in-out;
}
#infoBox:hover {
    background-color: rgba(65, 58, 75, 0.75);
}

.searchIconImage {        /* !!!!!!!!!!  make is change between a ! and the loupe depending on if its currently showing info or not!!!!!!!!!!!!!!!!!!!!!!!! */
    position: absolute;
    left: 10px; /* Adjust position */
    top: 50%;
    transform: translateY(-50%); /* Centers the icon vertically */
    width: 16px; /* Adjust size */
    height: auto;
    pointer-events: none;
}

.toolActivated {
    background-color: rgba(65, 58, 75, 0.75);
    border: solid 1px rgba(194, 194, 194, 1);
}

/* Link tool: only usable in XY view; XZ/YZ use disabled + .linkToolUnavailable */
#linkToolButton:disabled,
#linkToolButton.linkToolUnavailable {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(0.35);
}

/* AI Assistant button: base for animations */
#Ai_activity_prediction {
    position: relative;
    overflow: hidden;
}

/* "on" label when AI is active; absolutely positioned so flex layout still centers only the image */
.aiButtonOnIndicator {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 11px;
    padding: 0;
    font-size: 11px;
    font-weight: 500;
    line-height: 1;
    letter-spacing: 0.02em;
    color: rgba(255, 255, 255, 0.7);
    pointer-events: none;
    white-space: nowrap;
    visibility: hidden;
    opacity: 0;
}

#Ai_activity_prediction.toolActivated .aiButtonOnIndicator {
    visibility: visible;
    opacity: 1;
}

/* Loading state: linear gradient moving right-to-left, shade shifts slightly */
#Ai_activity_prediction.aiAssistantLoading::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(90, 60, 130, 0.2) 25%,
        rgba(130, 85, 170, 0.5) 50%,
        rgba(90, 60, 130, 0.2) 75%,
        transparent 100%
    );
    background-size: 200% 100%;
    background-repeat: repeat-x;
    animation: aiGlowSlide 1.8s linear infinite;
    pointer-events: none;
}

#Ai_activity_prediction.aiAssistantLoading .buttonImages {
    position: relative;
    z-index: 1;
}

@keyframes aiGlowSlide {
    0%   { background-position: 200% 0;   filter: brightness(1);   opacity: 0.95; }
    25%  { background-position: 100% 0;   filter: brightness(1.08); opacity: 0.88; }
    50%  { background-position: 0% 0;     filter: brightness(0.92); opacity: 0.95; }
    75%  { background-position: -100% 0; filter: brightness(1.05); opacity: 0.9; }
    100% { background-position: -200% 0; filter: brightness(1);   opacity: 0.95; }
}

/* Deciding state: image inside the button bounces (scale up → down), button stays still */
#Ai_activity_prediction.aiAssistantDeciding #aiButtonImage {
    animation: aiImageBounce 0.7s ease-in-out infinite;
}

@keyframes aiImageBounce {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.18); }
    70%  { transform: scale(0.95); }
    100% { transform: scale(1); }
}

/* Task complete: full button bounces once */
#Ai_activity_prediction.aiAssistantTaskComplete {
    animation: aiButtonBounce 0.45s ease-out;
}

@keyframes aiButtonBounce {
    0%   { transform: scale(1); }
    45%  { transform: scale(1.13); }
    75%  { transform: scale(0.97); }
    100% { transform: scale(1); }
}

button {
    /* margin: 5px; */
    color: rgb(255, 255, 255);
    background-color: rgba(42, 37, 48, 0.75);
    border: solid 1px rgba(42, 37, 48, 0.75);
    /* border: none; */
    width: 70px;
    height: 30px;
    /* border-radius: 0px; */
    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 2px;

    /* border-radius: 15px; */
    transition: transform 0.1s ease-in-out, background-color 0.1s ease-in-out, border 0.1s ease-in-out;
}

#tutorialButton {
    width: 40px;
}

#tutorialButtonImage {
    transform: scale(1.1);
}

#saveButton {
    width: 40px;
}

#mainMenuButton {
    width: 40px;
}

button:hover {
    background-color:  rgba(81, 72, 94, 0.75);
    cursor: pointer;
    transform: scale(1.03);
}

button:active {
    background-color:  rgba(65, 58, 75, 0.75);
    border: solid 1px rgba(194, 194, 194, 0.75);
    transform: scale(0.98);
}

/* button:focus:not(:focus-visible) {
  outline: none;
} */

button:focus {
    outline: none;
}

.buttonImages {
    max-width: 70%;
    max-height: 70%;
    object-fit: contain;
    display: block;
}

#resetButtonImage {
    max-width: 65%;
    max-height: 65%;
}

#moveButtonImage {
    max-width: 75%;
    max-height: 75%;
}

#aiButtonImage {
    max-width: 73%;
    max-height: 73%;
}

#toolBar {
    background-color: rgba(52, 29, 61, 0.5);
    /* background-color: rgba(43, 35, 46, 0.5); */
    padding: 0 8px;
    display: flex;
    align-items: center;
    border-radius: 5px;

    /* box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.1); */
    
    /* outline: 1px solid rgba(255, 255, 255, 0.1); */
    /* outline-offset: -1px; */
}

.leftSideToolBarrArea,
.rightSideToolBarrArea {
    display: flex;
    align-items: center;
    gap: 6px;
}

.rightSideToolBarrArea {
    margin-left: auto;
}

/* Narrow toolbar controls (same width as right-side icon buttons), separated from main left tools */
.leftToolbarSeparator {
    width: 1px;
    height: 22px;
    align-self: center;
    flex-shrink: 0;
    margin-left: 2px;
    margin-right: 2px;
    background: rgba(255, 255, 255, 0.22);
    border-radius: 1px;
}

#spaceManagerButton {
    width: 40px;
}

#spaceManagerButtonImage {
    transform: scale(0.85);
}

#gridArea {
    /* border: 4px solid rgba(52, 29, 61, 0.5); */
    /* border: 4px solid rgba(42, 37, 48, 1); */
    border: none;
    border-radius: 5px;
    overflow: hidden;
    height: 100%;
    width: 100%;
    position: relative;
    top: 5px;
    background-color: rgba(42, 37, 48, 1);
    /* shadow moved to ::before so it appears on top of grid blocks */

    /* reduce edge/rendering artifacts */
    transform: translateZ(0);
    will-change: transform;
    isolation: isolate;
    backface-visibility: hidden;

    /* outline: 1px solid rgba(255, 255, 255, 0.1); */
    /* outline-offset: 1px; */

    /* Rubberband edge glow: JS sets these 0–1 per edge; ::after uses them for box-shadow */
    --edge-glow-l: 0;
    --edge-glow-r: 0;
    --edge-glow-t: 0;
    --edge-glow-b: 0;
}

#gridArea.isGridDragging,
#gridArea.isGridDragging * {
    cursor: grabbing !important;
}


#gridArea::before {
    content: "";
    position: absolute;
    /* extend 1px past edge so overlay covers clipping seam; overflow:hidden clips this */
    inset: -1px;
    pointer-events: none;
    z-index: 10;
    /* radius +1 so corner still matches when clipped by parent */
    border-radius: 5px;
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.4);
}

/* Rubberband edge glow: box-shadow on the edge that is past the bound (variables set by JS). Subtle white hint only. */
#gridArea::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 11;
    border-radius: 5px;
    box-shadow:
        inset 8px 0 20px -4px rgba(255, 255, 255, calc(0.1 * var(--edge-glow-l))),
        inset -8px 0 20px -4px rgba(255, 255, 255, calc(0.1 * var(--edge-glow-r))),
        inset 0 8px 20px -4px rgba(255, 255, 255, calc(0.1 * var(--edge-glow-t))),
        inset 0 -8px 20px -4px rgba(255, 255, 255, calc(0.1 * var(--edge-glow-b)));
}

/* #gridArea::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;

    background:
        radial-gradient(
            ellipse at center,
            transparent 70%,
            rgba(0, 0, 0, 0.25) 100%
        );
} */

::-webkit-scrollbar {
  display: none;
}

#panLayer {
    position: absolute;
    left: 0;
    top: 0;
}

#draggableArea {
    border-radius: 5px;
    background-color: rgba(42, 37, 48, 1);
    display: grid;
    grid-template-columns: repeat(100, 190px);
    grid-template-rows: repeat(50, 140px);
    grid-gap: 60px;
    /* overflow: hidden; */
    position: absolute;
    transform-origin: 0 0;
    /* top: -90px;
    left: -90px; */
    cursor: grab;
    padding: 160px;
    /* z-index: 4; */

    outline: 3px solid #ffffff1f;
    outline-offset: 0px;
}

/* .grids:hover {
    border: 1px solid rgb(163, 163, 163);
    background-color: rgb(212, 212, 212);
    border-radius: 5px;
    margin: 5px;
    cursor: pointer;
    position: relative;
    overflow: visible;
}

.grids {
    border: 1px solid rgb(200, 200, 200);
    background-color: rgb(200, 200, 200);
    border-radius: 5px;
    margin: 5px;
    cursor: pointer;
    position: relative;
    overflow: visible;
} */

.grids {
    /* Same grey as `.active`, very transparent so empty cells read as subtle glass tiles */
    border: 1px solid rgba(212, 212, 212, 0.35);
    background-color: rgba(212, 212, 212, 0.14);
    /* border-radius: 5px; */
    margin: 5px;
    cursor: pointer;
    position: relative;
    overflow: visible;
    box-sizing: border-box;

    border-radius: 5px;
}

.active {
    /* width: 190px;
    height: 140px; */
    /* background-color: rgb(56, 50, 64); */
    /* border: 4px solid rgba(230, 230, 230, 1);
    background-color: rgba(230, 230, 230, 1); */

    border: 2px solid rgb(212, 212, 212);
    background-color: rgb(212, 212, 212);


    /* border: none; */
    /* border-radius: 5px; */
}

div.selected {
    /* border: 3px solid rgba(155, 39, 39, 1); */
    /* border-radius: 5px; */
    filter: drop-shadow(0 0 10px #3f9426);
    /* border: 4px solid #d1650d; */
    outline: 2px solid #3f9426;
    outline-offset: 2px;
}

div.selectedSecond {
    filter: drop-shadow(0 0 10px #d1650d);
    outline: 2px solid #d1650d;
    outline-offset: 2px;
}

.textbox {
    position: absolute;
    /* background-color: rgb(213, 213, 213); */
    /* background-color: rgba(109, 48, 137, 0.2); */
    /* background-color: rgba(197, 197, 197, 0.9); */
    /* background-color: rgba(175, 175, 175, 0.9); */
    background-color: transparent;
    border: none;
    /* border: 1px solid rgb(213, 213, 213); */
    /* border-radius: 3px; */
    font-size: 12px;
    text-align: center;
    padding: 2px;
    color: rgb(75, 75, 75);
}

.textbox::placeholder {
        color: rgb(75, 75, 75);
}

.textbox.ES, .textbox.LS, .textbox.TF,
.textbox.EF, .textbox.LF, .textbox.FF {
    width: 30px;
    height: 25px;
}

.textbox.activeGridNumber {
    /* width: 65px; */
    width: 71px;
    height: 17px;
    transform: translateX(-50%);

    /* border-width: 1px;                                                       <<----------------------- */
    border-width: 0 1px 0 1px; /*top right bottom left */
    border-style: solid;
    border-color: rgba(175, 175, 175, 0.9);
}

.textbox.ES { top: 25%; left: 5%; }
.textbox.LS { top: 47%; left: 5%; 
    
    /* border-width: 1px;                                                       <<----------------------- */
    border-width: 1px 0 1px 0; /*top right bottom left */
    border-style: solid;
    border-color: rgba(175, 175, 175, 0.9);
}
.textbox.TF { top: 74%; left: 5%;}
.textbox.EF { top: 25%; right: 5%;}
.textbox.LF { top: 47%; right: 5%; 

    /* border-width: 1px;                                                       <<----------------------- */
    border-width: 1px 0 1px 0; /*top right bottom left */
    border-style: solid;
    border-color: rgba(175, 175, 175, 0.9);
}
.textbox.FF { top: 74%; right: 5%;}
.textbox.activeGridNumber { top: 77%; left: 50%;}

.textbox.Name { 
    top: 7%; 
    left: 50%; 
    transform: translateX(-50%);
    background-color: white;
    width: 155px; 
    height: 19px;
    pointer-events: auto;
    z-index: 100;

    /* border-radius: 2px 2px 0 0; */

    border-radius: 2px;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.5) inset;
}

.textbox.Duration { 
    top: 31%; 
    left: 50%; 
    transform: translateX(-50%);
    background-color: white;
    width: 66px; 
    height: 45px;
    font-size: 12px;
    pointer-events: auto;
    z-index: 100;

    border-radius: 2px;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.5) inset;
}

input:focus {
    /* outline: 1px solid rgba(194, 194, 194, 0.5); */
    outline: 1px solid rgba(194, 194, 194, 1)
}

input[type="number"] {
    appearance: textfield;
}
  
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

#linkArrows {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background: transparent;
    inset: 0;
    pointer-events: auto;
}

.critical {
    color: rgb(194, 0, 0);
    /* background-color: rgb(194, 0, 0); */
    
    border: 2px solid rgb(194, 0, 0);
    box-shadow: 0 0 5px rgb(194, 0, 0) inset;
    stroke: rgb(194, 0, 0);
}

.linkDelay.critical {
    --critical-delay-color: rgb(194, 0, 0);
}

.hoveredLink {
    /* stroke: red; */
    stroke-width: 7;
    filter: drop-shadow(0 0 16px #ffffffeb);
    cursor: pointer;
}

div.hoveredAcvtiveGrid {
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.61) !important;
    border-radius: 5px !important;
    cursor: pointer;
}

div.hoveredNonAcvtiveGrid {
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.305) !important;
    border-radius: 5px !important;
    cursor: pointer;
}

path {
    pointer-events: stroke;
    cursor: pointer;
}

.linkDelay {
    position: absolute;
    transform: translate(-50%, -50%);
    /* border: 3px solid rgba(0, 0, 0, 0.6); */
    /* border: 3px solid var(--delay-color, rgba(0,0,0,0.6)); */
    border-style: solid;
    border-width: 3px;
    border-color: var(--critical-delay-color, var(--delay-color, rgba(0,0,0,0.6)));
    border-radius: 18px;
    font-size: 12px;
    text-align: center;
    padding: 2px;
    color: rgb(75, 75, 75);
    z-index: 100;
    background-color: white;
    width: 40px; 
    height: 18px;
    pointer-events: auto;
}

.linkDelay3d {
    position: relative !important;
    transform: none !important;
    left: auto !important;
    top: auto !important;
}

#arrowDelays {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: transparent;
}

footer {
    text-align: center;
    color: rgba(87, 76, 100, 1);
    font-size: 10px;
    font-family: Verdana, Geneva, Tahoma, sans-serif;
}

.SugestedBlock {
    outline: 2px solid rgba(230, 180, 80, 0.5);
    outline-offset: 2px;
}

/* Per-activity Accept / Reject buttons attached to each suggested .grids block.
   Hosted INSIDE the .grids element so they follow the block in 2D and 3D (the
   .grids element is reparented into a CSS3DObject in 3D view). */
.suggestionPerBlockBtns {
    position: absolute;
    top: -34px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    z-index: 200;
    pointer-events: auto;
    white-space: nowrap;
}

.suggestionPerBlockBtns .suggestionAcceptBtn,
.suggestionPerBlockBtns .suggestionRejectBtn {
    padding: 4px 10px;
    font-size: 11px;
    border-radius: 4px;
    cursor: pointer;
    border: none;
    font-family: Verdana, Geneva, Tahoma, sans-serif;
    background: rgba(212, 212, 212, 0.9);
    color: rgba(42, 37, 48, 1);
}

.suggestionPerBlockBtns .suggestionAcceptBtn {
    outline: 2px solid #409426c7;
}

.suggestionPerBlockBtns .suggestionAcceptBtn:hover {
    background: rgb(212, 212, 212);
}

.suggestionPerBlockBtns .suggestionRejectBtn {
    outline: 2px solid #d1650dc7;
}

.suggestionPerBlockBtns .suggestionRejectBtn:hover {
    background: rgb(212, 212, 212);
}

/* Selection by rectangle: marquee while dragging */
.selectionMarqueeWrapper {
    z-index: 140;
    box-sizing: border-box;
    pointer-events: none;
}

.selectionMarqueeShape {
    border: 2px dashed rgba(80, 140, 230, 0.9);
    background: rgba(80, 140, 230, 0.1);
    border-radius: 6px;
}

/* Selection result wrapper (like suggestionBoundsWrapper) with Delete */
.selectionBoundsWrapper {
    z-index: 150;
    box-sizing: border-box;
    cursor: move;
    transition: left 0.12s ease-out, top 0.12s ease-out, width 0.12s ease-out, height 0.12s ease-out;
}

.selectionBoundsShape {
    position: absolute;
    inset: 0;
    border: 2px dashed rgba(80, 140, 230, 0.9);
    background: rgba(80, 140, 230, 0.08);
    border-radius: 8px;
    pointer-events: none;
}

/* Tutorial popup overlay and window (styled like active grids) */
.tutorialPopupOverlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    background-color: rgba(0, 0, 0, 0.4);
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.tutorialPopupOverlay.tutorialPopupOpen {
    display: flex;
}

.tutorialPopupWindow {
    /* Match active grid styling: border and background */
    border: 2px solid rgb(212, 212, 212);
    background-color: rgb(212, 212, 212);
    border-radius: 5px;
    max-width: 520px;
    max-height: 85vh;
    overflow: auto;
    box-sizing: border-box;
    padding: 20px 24px 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    position: relative;
}

.tutorialPopupTitle {
    margin: 0 0 14px 0;
    font-size: 1.2rem;
    color: rgb(75, 75, 75);
    font-weight: 600;
}

.tutorialPopupContent {
    color: rgb(75, 75, 75);
    font-size: 13px;
    line-height: 1.45;
}

.tutorialSection {
    margin-bottom: 14px;
    padding: 6px 8px;
    margin-left: -8px;
    margin-right: -8px;
    border-radius: 4px;
    cursor: default;
    transition: background-color 0.15s ease;
}

.tutorialSection:hover {
    background-color: rgba(0, 0, 0, 0.06);
}

.tutorialSectionHeader {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

.tutorialSectionButtonMock {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 25px;
    height: 25px;
    flex-shrink: 0;
    background-color: #2e2636;
    border: solid 1px rgba(42, 37, 48, 0.75);
    border-radius: 2px;
}

.tutorialSectionButtonMock img {
    max-width: 70%;
    max-height: 70%;
    object-fit: contain;
    display: block;
}

/* Movement controls: mock button with different color (pan/move tool) */
.tutorialSectionButtonMockMovement {
    background-color: rgba(52, 29, 61, 0.9);
    border: solid 1px rgba(120, 100, 140, 0.9);
}

.tutorialSectionHeader .tutorialSectionButtonMock + h3,
.tutorialSectionHeader .tutorialSectionGridMock + h3,
.tutorialSectionHeader .tutorialSectionSelectionMock + h3 {
    margin: 0;
}

/* Mock active grid: same size as mock buttons, active grid styling */
.tutorialSectionGridMock {
    display: inline-block;
    width: 25px;
    height: 25px;
    flex-shrink: 0;
    border: 1px solid rgb(129, 129, 129);
    background-color: rgb(212, 212, 212);
    border-radius: 5px;
    box-sizing: border-box;
}

/* Mock selection wrapper: same size, selection bounds styling */
.tutorialSectionSelectionMock {
    display: inline-block;
    width: 25px;
    height: 25px;
    flex-shrink: 0;
    border: 2px dashed rgba(80, 140, 230, 0.9);
    background: rgba(80, 140, 230, 0.08);
    border-radius: 6px;
    box-sizing: border-box;
}

.tutorialSection h3 {
    margin: 0 0 4px 0;
    font-size: 13px;
    font-weight: 600;
    color: rgb(55, 55, 55);
}

.tutorialSection p {
    margin: 0;
}

.tutorialPopupHint {
    margin: 14px 0 0 0;
    font-size: 11px;
    color: rgba(75, 75, 75, 0.8);
}

#tutorialButton.toolActivated {
    background-color: rgba(65, 58, 75, 0.75);
    border: solid 1px rgba(194, 194, 194, 1);
}

/* Section preview panel (next to tutorial window, same style as active grids) */
.tutorialSectionPreview {
    display: none;
    position: fixed;
    border: 2px solid rgb(212, 212, 212);
    background-color: rgb(212, 212, 212);
    border-radius: 5px;
    width: 260px;
    max-width: calc(100vw - 40px);
    box-sizing: border-box;
    padding: 14px 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    z-index: 10001;
    pointer-events: auto;
}

.tutorialSectionPreview.tutorialSectionPreviewVisible {
    display: block;
}

.tutorialSectionPreviewMedia {
    width: 100%;
    aspect-ratio: 16 / 10;
    background-color: rgba(0, 0, 0, 0.06);
    border-radius: 4px;
    margin-bottom: 10px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.tutorialSectionPreviewImg {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.tutorialSectionPreviewImg:not([src]),
.tutorialSectionPreviewImg[src=""] {
    display: none;
}

.tutorialSectionPreviewVideo {
    display: none;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.tutorialSectionPreviewMedia.tutorialSectionPreviewHasVideo .tutorialSectionPreviewImg {
    display: none !important;
}

.tutorialSectionPreviewMedia.tutorialSectionPreviewHasVideo .tutorialSectionPreviewVideo {
    display: block;
}

.tutorialSectionPreviewText {
    margin: 0;
    font-size: 12px;
    line-height: 1.4;
    color: rgb(75, 75, 75);
}

/* ---- AI Password popup ---- */
.aiPasswordPopupOverlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10001;
    background-color: rgba(0, 0, 0, 0.45);
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.aiPasswordPopupOverlay.aiPasswordPopupOpen {
    display: flex;
}

.aiPasswordPopupWindow {
    border: 2px solid rgb(212, 212, 212);
    background-color: rgb(212, 212, 212);
    border-radius: 5px;
    width: 300px;
    box-sizing: border-box;
    padding: 20px 22px 18px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.28);
    position: relative;
}

.aiPasswordPopupTitle {
    margin: 0 0 14px 0;
    font-size: 1.1rem;
    color: rgb(55, 55, 55);
    font-weight: 600;
}

.aiPasswordForm {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.aiPasswordInput {
    width: 100%;
    box-sizing: border-box;
    padding: 7px 10px;
    border: 1px solid rgba(150, 150, 150, 0.6);
    border-radius: 3px;
    background-color: rgba(255, 255, 255, 0.85);
    color: rgb(40, 40, 40);
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s ease;
}

.aiPasswordInput:focus {
    border-color: rgba(130, 85, 170, 0.7);
}

.aiPasswordError {
    margin: 0;
    min-height: 16px;
    font-size: 11.5px;
    color: rgb(180, 40, 40);
}

.aiPasswordButtons {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.aiPasswordSubmitBtn {
    width: auto;
    padding: 0 16px;
    height: 28px;
    font-size: 12.5px;
    background-color: rgba(90, 60, 130, 0.85);
    border: solid 1px rgba(130, 85, 170, 0.8);
    color: white;
    border-radius: 3px;
    cursor: pointer;
    transition: background-color 0.1s ease;
}

.aiPasswordSubmitBtn:hover {
    background-color: rgba(110, 75, 155, 0.9);
    transform: scale(1.02);
}

.aiPasswordCancelBtn {
    width: auto;
    padding: 0 14px;
    height: 28px;
    font-size: 12.5px;
    background-color: rgba(42, 37, 48, 0.55);
    border: solid 1px rgba(150, 150, 150, 0.5);
    color: white;
    border-radius: 3px;
    cursor: pointer;
    transition: background-color 0.1s ease;
}

.aiPasswordCancelBtn:hover {
    background-color: rgba(65, 58, 75, 0.75);
    transform: scale(1.02);
}

/* ---- 3D Canvas ---- */
#threeDCanvas {
    position: absolute;
    top: 0;
    left: 0;
    display: block;
    width: 100%;
    height: 100%;
    z-index: 5;
    border-radius: 5px;
}

/* CSS2D label layer rendered above the WebGL canvas. */
#threeDLabelLayer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 6;
    pointer-events: none;
    overflow: hidden;
    transform-style: preserve-3d;
}

/* CSS2D label DOM elements: re-enable pointer events only on the inputs themselves. */
.threeBlockLabel {
    position: absolute;
    pointer-events: none;
    transform: translate(-50%, -50%);
    user-select: none;
    /* sized to roughly match the 2D block face (CELL_W=190, CELL_H=140 in world units) */
    width: 190px;
    height: 140px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    padding: 8px 6px 6px 6px;
    box-sizing: border-box;
    color: #222;
    font-family: 'Google Sans', sans-serif;
    font-size: 12px;
}

.threeBlockLabel .threeBlockName,
.threeBlockLabel .threeBlockDuration {
    pointer-events: auto;
    background-color: rgba(255,255,255,0.92);
    border: 1px solid rgba(120,120,120,0.5);
    border-radius: 3px;
    padding: 2px 6px;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 12px;
    color: #222;
    outline: none;
    text-align: center;
}

.threeBlockLabel .threeBlockName {
    width: 155px;
    height: 22px;
}

.threeBlockLabel .threeBlockDuration {
    width: 66px;
    height: 30px;
    font-weight: 600;
    font-size: 14px;
}

.threeBlockLabel .threeBlockMeta {
    pointer-events: none;
    font-size: 10px;
    color: rgba(40,40,40,0.65);
    text-align: center;
    line-height: 1.15;
    margin-top: 2px;
}

.threeBlockLabel .threeBlockNo {
    pointer-events: none;
    font-size: 10px;
    color: rgba(40,40,40,0.55);
}

/* When the underlying block is selected/critical, highlight the label slightly. */
.threeBlockLabel.threeBlockLabelSelected .threeBlockName,
.threeBlockLabel.threeBlockLabelSelected .threeBlockDuration {
    border-color: rgba(255,165,0,0.9);
    box-shadow: 0 0 0 2px rgba(255,165,0,0.35);
}

.threeBlockLabel.threeBlockLabelHovered .threeBlockName,
.threeBlockLabel.threeBlockLabelHovered .threeBlockDuration {
    border-color: rgba(80,160,255,0.9);
}

.threeBlockLabel.threeBlockLabelCritical .threeBlockName {
    color: #b00;
}

/* View preset buttons (XY / XZ / YZ) reuse the existing toolbar button look (.View_toggle). */
.viewPresetBtn .viewPresetLabel {
    font-size: 13px;
    font-weight: 700;
    color: white;
    pointer-events: none;
    letter-spacing: 0.5px;
}

/* Active preset highlighted via .toolActivated which already exists in CSS. */

/* Axis overlays sit inside #gridArea on top of the 3D canvas. */
.axisOverlay {
    position: absolute;
    z-index: 7;
    pointer-events: none;
    color: #ddd;
    font-family: 'Google Sans', sans-serif;
    font-size: 11px;
    letter-spacing: 0.3px;
    text-shadow: 0 0 3px rgba(0,0,0,0.6);
}

.axisOverlayH {
    top: 0px;
    left: 23px;
    right: 12px;
    height: 28px;
}

.axisOverlayV {
    top: 20px;
    left: 12px;
    bottom: 12px;
    width: 52px;
}

.axisOverlayTitle {
    position: absolute;
    font-weight: 600;
    font-size: 11px;
    color: rgba(255,255,255,0.78);
    /* background: rgba(0,0,0,0.35); */
    background: #18151b;
    padding: 1px 6px;
    border-radius: 3px;
    white-space: nowrap;
    z-index: 2;
}

.axisOverlayH .axisOverlayTitle {
    left: 5px;
    top: 10px;
}

.axisOverlayV .axisOverlayTitle {
    top: 0px;
    left: -56px;
    transform: rotate(-90deg);
    transform-origin: right;
}

/* Keep the Y-axis title aligned to the same visual anchor as before the
 * label text changed from "zone" to "space". */
.axisOverlayV .axisOverlayTitle[data-axis="Y"] {
    left: -62.5px;
}

/* In XZ view the vertical axis represents Z. Pull its title closer to the
 * left edge of the grid area (other views are unchanged). */
.axisOverlayV .axisOverlayTitle[data-axis="Z"] {
    left: -92.5px;
}

.axisOverlayTicks {
    position: absolute;
    inset: 0;
    z-index: 1;
}

.axisOverlayTick {
    position: absolute;
    color: rgba(255,255,255,0.78);
    font-size: 10px;
    white-space: nowrap;
    transform: translate(-50%, 0);
}

.axisOverlayTick.axisOverlayTickClickable {
    pointer-events: auto;
    cursor: pointer;
    color: rgba(255,255,255,0.92);
}

.axisOverlayTick.axisOverlayTickClickable:hover {
    color: rgba(255,255,255,1);
    text-shadow: 0 0 6px rgba(255,255,255,0.45);
}

.axisOverlayH .axisOverlayTick {
    top: 12px;
}

.axisOverlayV .axisOverlayTick {
    left: 6px;
    transform: translate(-50%, -50%) rotate(-90deg);
    transform-origin: center center;
}

.axisOverlayTick::before {
    content: '';
    position: absolute;
    background: rgba(255,255,255,0.45);
}

.axisOverlayH .axisOverlayTick::before {
    width: 1px;
    height: 6px;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
}

.axisOverlayV .axisOverlayTick::before {
    width: 1px;
    height: 6px;
    left: 50%;
    top: -8px;
    transform: translateX(-50%);
}

#gridArea.is3dMode #panLayer {
    display: none !important;
}

/* Wrapper around an active .grids element when re-parented into the CSS2D label layer.
 * CSS2DRenderer applies translate3d() to this element. We give it the same logical size
 * as a 2D grid cell so the percentage-positioned `.textbox` children render correctly. */
.threeBlockWrapper {
    pointer-events: auto;          /* let the .grids itself receive native click/dblclick/mouseenter */
    transform: translate(-50%, -50%);
    box-sizing: border-box;
    transform-style: preserve-3d;
}

.threeBlockWrapper > .grids {
    margin: 0 !important;          /* the 5px default margin would offset positioning */
    width: 100%;
    height: 100%;
    position: relative;
    pointer-events: auto;
}

/* Native CSS hover state on the active block (mirrors the 2D `.hoveredAcvtiveGrid` look). */
.threeBlockWrapper:hover > .grids {
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.61);
    border-radius: 5px;
    cursor: pointer;
}

/* 3D inactive-cell hover tile (CSS3D object): same glow shape as active, half brightness. */
.threeInactiveHoverCell {
    box-sizing: border-box;
    border-radius: 5px;
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.305);
    background-color: rgba(212, 212, 212, 0.06);
    pointer-events: none;
}


/* ---- Space Manager Popup ---- */
.spaceManagerPopupOverlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    background-color: rgba(0, 0, 0, 0.4);
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.spaceManagerPopupOverlay.spaceManagerPopupOpen {
    display: flex;
}

.spaceManagerPopupWindow {
    border: 2px solid rgb(212, 212, 212);
    background-color: rgb(212, 212, 212);
    border-radius: 5px;
    width: 380px;
    max-height: 75vh;
    overflow: auto;
    box-sizing: border-box;
    padding: 20px 22px 18px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.28);
    position: relative;
}

.spaceManagerPopupTitle {
    margin: 0 0 4px 0;
    font-size: 1.15rem;
    color: rgb(55, 55, 55);
    font-weight: 600;
}

.spaceManagerPopupHint {
    margin: 0 0 14px 0;
    font-size: 11px;
    color: rgba(75, 75, 75, 0.8);
}

.spaceManagerList {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.spaceManagerRow {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.55);
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 12.5px;
    color: rgb(55, 55, 55);
}

.spaceManagerSwatch {
    display: inline-block;
    width: 18px;
    height: 18px;
    border-radius: 3px;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.15);
}

.spaceManagerSwatch.spaceSwatchNoFill {
    background-color: transparent;
    background-image: none;
}

.spaceManagerName {
    flex: 1 1 auto;
    font-weight: 500;
}

.spaceManagerZ {
    flex: 0 0 auto;
    font-size: 11px;
    color: rgb(100, 100, 100);
    min-width: 36px;
}

.spaceManagerEditBtn,
.spaceManagerDeleteBtn {
    width: auto;
    min-width: 48px;
    height: 22px;
    font-size: 11px;
    border-radius: 3px;
    cursor: pointer;
    padding: 0 8px;
}

.spaceManagerEditBtn {
    background-color: rgba(90, 60, 130, 0.18);
    color: rgb(70, 45, 110);
    border: 1px solid rgba(90, 60, 130, 0.3);
}

.spaceManagerDeleteBtn {
    background-color: rgba(180, 50, 50, 0.15);
    color: rgb(140, 35, 35);
    border: 1px solid rgba(180, 50, 50, 0.28);
}

.spaceManagerAddArea {
    margin-bottom: 10px;
}

.spaceManagerAddBtn {
    width: auto;
    padding: 0 14px;
    height: 28px;
    font-size: 12.5px;
    background-color: rgba(90, 60, 130, 0.85);
    border: solid 1px rgba(130, 85, 170, 0.8);
    color: white;
    border-radius: 3px;
    cursor: pointer;
    transition: background-color 0.1s ease;
}

.spaceManagerAddBtn:hover {
    background-color: rgba(110, 75, 155, 0.9);
    transform: scale(1.02);
}

.spaceManagerForm {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(255, 255, 255, 0.45);
    border-radius: 4px;
    padding: 10px;
}

.spaceFormInput {
    width: 100%;
    box-sizing: border-box;
    padding: 6px 8px;
    border: 1px solid rgba(150, 150, 150, 0.5);
    border-radius: 3px;
    background-color: rgba(255, 255, 255, 0.85);
    color: rgb(40, 40, 40);
    font-size: 13px;
    outline: none;
}

.spaceFormInput:focus {
    border-color: rgba(130, 85, 170, 0.7);
}

.spaceFormInlineError {
    margin-top: -4px;
    font-size: 11px;
    color: rgb(165, 32, 32);
    min-height: 14px;
}

.spaceFormInput.spaceFormInputError {
    border-color: rgba(165, 32, 32, 0.9);
}

.spaceFormColor {
    width: 42px;
    height: 30px;
    padding: 0;
    border: 1px solid rgba(150, 150, 150, 0.5);
    border-radius: 3px;
    cursor: pointer;
    background: none;
}

.spaceFormLabel {
    font-size: 12px;
    color: rgb(75, 75, 75);
    display: flex;
    align-items: center;
    gap: 8px;
}

.spaceFormZInput {
    width: 60px;
    flex: 0 0 auto;
}

.spaceFormButtons {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    align-items: center;
}

.spaceFormListBtn {
    margin-right: auto;
    width: auto;
    padding: 0 12px;
    height: 26px;
    font-size: 12px;
    background-color: rgba(42, 37, 48, 0.55);
    border: solid 1px rgba(150, 150, 150, 0.5);
    color: white;
    border-radius: 3px;
    cursor: pointer;
}

.spaceFormListBtn:hover {
    background-color: rgba(65, 58, 75, 0.75);
    transform: scale(1.02);
}

.spaceFormSaveBtn {
    width: auto;
    padding: 0 14px;
    height: 26px;
    font-size: 12px;
    background-color: rgba(90, 60, 130, 0.85);
    border: solid 1px rgba(130, 85, 170, 0.8);
    color: white;
    border-radius: 3px;
    cursor: pointer;
}

.spaceFormSaveBtn:hover {
    background-color: rgba(110, 75, 155, 0.9);
    transform: scale(1.02);
}

.spaceFormDeleteBtn {
    width: auto;
    padding: 0 12px;
    height: 26px;
    font-size: 12px;
    background-color: rgba(135, 38, 38, 0.86);
    border: solid 1px rgba(170, 58, 58, 0.9);
    color: white;
    border-radius: 3px;
    cursor: pointer;
}

.spaceFormDeleteBtn:hover {
    background-color: rgba(160, 46, 46, 0.95);
    transform: scale(1.02);
}
