.student-skylt-wrap {
    width: calc(100% - 24px);
    max-width: 1200px;
    margin: 12px auto;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    box-sizing: border-box;
    position: relative;
    padding-left: 12px;
    padding-right: 12px;
}

.student-skylt-sidebar {
    width: 220px;
    min-width: 220px;
    flex: 0 0 220px;
    background: #ffffff;
    border: 1px solid #d9e0ea;
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(13, 30, 61, 0.06);
    padding: 8px;
    box-sizing: border-box;
    position: sticky;
    top: 12px;
    /* Allow sidebar to expand instead of scrolling */
    max-height: none;
    overflow: visible;
}

.student-skylt-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    box-sizing: border-box;
}

.student-skylt-canvas-box {
    flex: 0 0 620px;
    min-width: 620px;
    background: #ffffff;
    border: 1px solid #d9e0ea;
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(13, 30, 61, 0.06);
    padding: 8px;
    box-sizing: border-box;
}

.student-skylt-preview-box {
    width: 230px;
    min-width: 230px;
    flex: 0 0 230px;
    background: #ffffff;
    border: 1px solid #d9e0ea;
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(13, 30, 61, 0.06);
    padding: 10px;
    box-sizing: border-box;
    position: sticky;
    top: 12px;
}

.student-skylt-sidebar h2,
.student-skylt-preview-box h3,
.student-skylt-canvas-header h3 {
    margin: 0 0 6px;
    font-size: 16px;
    line-height: 1.1;
    font-weight: 600;
}

.student-panel {
    margin-bottom: 9px;
    padding-bottom: 4px;
    border-bottom: 1px solid #3d3d3d;
}

.student-panel:last-child {
    border-bottom: 0;
    margin-bottom: 0;
    padding-bottom: 0;
}

.student-panel h3 {
    margin: 0 0 0px;
    font-size: 13px;
    line-height: 1.05;
    font-weight: 600;
}

.student-skylt-sidebar label {
    display: block;
    margin-bottom: 2px;
    font-weight: 600;
    font-size: 11px;
}

/* Reduce vertical gap between section heading and the first control */
.student-panel > *:not(h3) {
    margin-top: 4px;
}

.student-panel h3 + * {
    margin-top: 2px;
}

.student-skylt-sidebar select,
.student-skylt-sidebar input[type="color"] {
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 6px;
    padding: 6px 8px;
    border: 1px solid #ccd4df;
    border-radius: 6px;
    background: #ffffff;
    font-size: 12px;
    min-height: 30px;
}

/* Smaller save-name input to reduce visual weight */
#student-save-name {
    font-size: 13px;
    padding: 6px 8px;
    min-height: 30px;
}

.student-skylt-sidebar input[type="color"] {
    height: 30px;
    padding: 2px;
}

.student-skylt-sidebar button {
    width: 100%;
    min-height: 30px;
    margin-bottom: 4px;
    border: 0;
    border-radius: 8px;
    background: #1f2b3d;
    color: #ffffff;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 8px;
    font-size: 12px;
    line-height: 1.1;
}

.student-skylt-sidebar button:hover,
.student-cart-button:hover {
    background: #2a3a55;
}

#student-photo-upload {
    display: none;
}

.student-upload-button {
    display: block;
    width: 100%;
    box-sizing: border-box;
    background: #1e5aa8;
    color: #ffffff;
    text-align: center;
    border-radius: 8px;
    padding: 9px 10px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    margin-bottom: 4px;
}

.student-upload-button:hover {
    background: #2568c2;
}

.student-upload-status,
.student-help {
    font-size: 11px;
    color: #5f6b7b;
    line-height: 1.25;
}

.student-cropper-box {
    margin-top: 4px;
    margin-bottom: 4px;
    border: 1px dashed #ccd4df;
    border-radius: 8px;
    padding: 4px;
    background: #f8fbff;
    min-height: 110px;
    max-height: 160px;
    overflow: hidden;
}

#student-cropper-image {
    display: none;
    max-width: 100%;
}

.student-text-row {
    display: grid;
    grid-template-columns: 1fr 34px;
    gap: 4px;
    margin-bottom: 4px;
}

.student-text-row input[type="text"] {
    width: 100%;
    box-sizing: border-box;
    padding: 6px 8px;
    border: 1px solid #ccd4df;
    border-radius: 6px;
    background: #ffffff;
    font-size: 12px;
    min-height: 30px;
}

.student-mini-add {
    min-width: 34px;
    padding: 0;
    font-size: 16px;
    margin-bottom: 0;
}

.student-skylt-canvas-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

#student-skylt-status {
    font-size: 12px;
    color: #5b6575;
}

.student-skylt-stage-scroll {
    /* Prevent horizontal scrollbar; center stage inside the scroll area */
    overflow-x: hidden;
    overflow-y: hidden;
    display: flex;
    justify-content: center;
}

#student-skylt-stage {
    width: 100%;
    max-width: 620px;
    height: 820px;
    min-width: 0;
    border: 0;
    border-radius: 12px;
    background: #ffffff;
    overflow: hidden;
    box-sizing: border-box;
    display: block;
}

.student-skylt-mockup {
    position: relative;
    width: 190px;
    margin: 8px auto 0;
    min-height: 350px;
}

.student-skylt-stick {
    position: absolute;
    left: 50%;
    top: 210px;
    width: 10px;
    height: 120px;
    background: linear-gradient(180deg, #a77545, #6a4322);
    transform: translateX(-50%);
    border-radius: 999px;
}

.student-skylt-thumb-frame {
    position: relative;
    z-index: 2;
    width: 170px;
    height: 238px;
    margin: 0 auto;
    border-radius: 8px;
    overflow: hidden;
    background: #ffffff;
    border: 6px solid #ffffff;
    box-shadow: 0 12px 28px rgba(13, 30, 61, 0.16);
}

#student-skylt-thumb {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}

.student-skylt-cart-box {
    margin-top: 10px;
}

.student-cart-option {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 12px;
    margin-bottom: 8px;
}

.student-cart-button {
    width: 100%;
    min-height: 32px;
    border: 0;
    border-radius: 8px;
    background: #1e5aa8;
    color: #ffffff;
    font-weight: 700;
    cursor: pointer;
}

.student-context-menu {
    position: fixed;
    z-index: 99999;
    background: #ffffff;
    border: 1px solid #d9e0ea;
    border-radius: 10px;
    box-shadow: 0 12px 28px rgba(13, 30, 61, 0.18);
    padding: 6px;
    display: none;
    width: 170px;
}

.student-context-menu.is-visible {
    display: block;
}

.student-context-menu button {
    width: 100%;
    display: block;
    border: 0;
    background: transparent;
    text-align: left;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    color: #1f2b3d;
}

.student-context-menu button:hover {
    background: #eef3f8;
}

.student-inline-text-editor {
    position: fixed;
    z-index: 100000;
    display: none;
    min-width: 160px;
    padding: 8px 10px;
    border: 1px solid #1e5aa8;
    border-radius: 8px;
    box-shadow: 0 12px 28px rgba(13, 30, 61, 0.18);
    background: #ffffff;
    font-size: 14px;
}

.student-inline-text-editor.is-visible {
    display: block;
}

/* Saved designs list: compact layout */
.student-saved-list {
    font-size: 13px;
    color: #1f2b3d;
}
.student-saved-ul { list-style: none; padding-left: 8px; margin: 0; }
.student-saved-ul li { margin: 6px 0; padding: 8px; border-radius: 8px; background: #fbfdff; border: 1px solid #eef4fb; }
.student-saved-item-info { display: flex; flex-direction: column; gap: 4px; }
.student-saved-item-info .title { font-weight: 700; font-size: 14px; }
.student-saved-item-info .meta { font-size: 11px; color: #6b7280; }
.student-saved-item-actions { margin-top: 6px; display: flex; gap: 8px; }
.student-saved-item-actions button { padding: 6px 10px; font-size: 12px; border-radius: 6px; border: 0; cursor: pointer; }
.student-saved-item-actions .open { background: #1f2b3d; color: #fff; }
.student-saved-item-actions .delete { background: #ff4d4f; color: #fff; }
.student-saved-item-actions .open, .student-saved-item-actions .delete { min-width: 78px; }


.student-object-toolbar {
    position: fixed;
    z-index: 100000;
    display: none;
    gap: 6px;
    align-items: center;
    /* Default: inline, left-aligned. Two-row will switch to wrapped/full-width input + action row. */
    flex-wrap: nowrap;
    justify-content: flex-start;
    background: #ffffff;
    border: 1px solid #d9e0ea;
    border-radius: 10px;
    box-shadow: 0 12px 28px rgba(13, 30, 61, 0.18);
    padding: 6px;
    box-sizing: border-box;
    /* allow toolbar to size to its contents to avoid large empty white area */
    max-width: 420px;
    width: auto;
    padding-right: 56px; /* room for absolute close button */
    padding-bottom: 6px;
}

.student-object-toolbar.is-visible {
    display: flex;
}

.student-object-toolbar input[type="text"] {
    width: 120px;
    min-height: 30px;
    padding: 6px 8px;
    border: 1px solid #ccd4df;
    border-radius: 8px;
    font-size: 12px;
}

/* Row wrapper for the primary inputs (text, font, color, rotation, close) */
.student-toolbar-row {
    display: flex;
    gap: 6px;
    align-items: center;
    width: auto; /* default: do not force full width so actions can sit inline */
}

/* Inputs do not flex by default; two-row will allow the text input to expand */
.student-toolbar-row > input[type="text"] {
    flex: 0 0 auto;
}

/* Two-row: stretch the input row to available toolbar width (reserve space for close button) */
.student-object-toolbar.two-row .student-toolbar-row {
    width: calc(100% - 56px);
}

.student-object-toolbar.two-row .student-toolbar-row > input[type="text"] {
    flex: 1 1 auto;
}

/* Ensure action row lines up exactly with the input row when two-row is applied */
.student-object-toolbar.two-row .student-toolbar-actions {
    width: calc(100% - 56px);
    margin-left: 0;
    justify-content: flex-start;
    /* match input row left padding so actions start exactly under inputs */
    padding-left: 6px;
    gap: 8px;
}

.student-object-toolbar select,
.student-object-toolbar input[type="color"] {
    min-height: 30px;
    padding: 4px 6px;
    border: 1px solid #ccd4df;
    border-radius: 8px;
    background: #ffffff;
    font-size: 12px;
    min-width: 56px;
}

.student-object-toolbar input[type="color"] {
    width: 36px;
    padding: 2px;
}

/* Close button for the floating object toolbar */
.student-object-toolbar .student-toolbar-close {
    position: absolute;
    right: 8px;
    top: 8px;
    background: transparent;
    border: 0;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    color: #1f2b3d;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.student-object-toolbar .student-toolbar-close:hover {
    background: #f2f6fb;
}

/* Small action buttons below the toolbar inputs */
.student-toolbar-actions {
    display: flex;
    gap: 6px;
    margin-left: 6px;
    margin-top: 0;
    align-items: center;
    flex-wrap: nowrap;
}

.student-toolbar-action {
    padding: 6px 8px;
    font-size: 13px;
    border-radius: 8px;
    border: 0;
    background: #f4f7fb;
    color: #1f2b3d;
    cursor: pointer;
    min-width: 76px;
}

/* compact icon variant for small toolbar buttons */
.student-toolbar-action.icon {
    min-width: 36px;
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.student-toolbar-action.icon svg {
    display: block;
}

.student-toolbar-action.danger {
    background: #1f2b3d;
    color: #fff;
}

.student-toolbar-action:hover {
    filter: brightness(0.95);
}

/* Two-row layout: used for text selection so actions sit beneath inputs */
.student-object-toolbar.two-row {
    flex-wrap: wrap;
    align-items: flex-start;
}

.student-object-toolbar.two-row .student-toolbar-actions {
    flex-basis: 100%;
    margin-left: 0;
    margin-top: 6px;
    justify-content: flex-start;
}

/* Default (non-two-row) keeps actions inline */
.student-object-toolbar:not(.two-row) .student-toolbar-actions {
    margin-left: 6px;
    margin-top: 0;
    flex-basis: auto;
}

@media (max-width: 1200px) {
    .student-skylt-wrap {
        flex-direction: column;
        margin-left: auto;
        margin-right: auto;
        width: calc(100% - 24px);
        padding-left: 12px;
        padding-right: 12px;
    }

    .student-skylt-sidebar,
    .student-skylt-preview-box,
    .student-skylt-canvas-box {
        width: 100%;
        min-width: 0;
        flex: none;
        position: static;
        max-height: none;
    }

    .student-skylt-main {
        width: 100%;
        flex-direction: column;
    }
}

@media (max-width: 800px) {
    /* Ensure sidebar and editor are full-width and centered on narrow screens */
    .student-skylt-wrap {
        padding-left: 8px;
        padding-right: 8px;
    }

    .student-skylt-sidebar {
        width: 100%;
        min-width: 0;
        margin-bottom: 12px;
    }

    .student-skylt-canvas-box {
        width: 100%;
        min-width: 0;
        padding: 6px;
    }

    /* Make sure stage container and mockup scale and center */
    .student-skylt-stage-scroll {
        justify-content: center;
    }
}

/* Compact button styles scoped to the editor to reduce visual weight */
.student-skylt-wrap button,
.student-skylt-wrap .student-skylt-sidebar button,
.student-skylt-wrap .student-cart-button,
.student-skylt-wrap .student-context-menu button,
.student-skylt-wrap .student-saved-item-actions button,
.student-skylt-wrap .student-toolbar-action,
.student-skylt-wrap .student-toolbar-close {
    font-size: 12px;
    padding: 6px 8px;
    min-height: 28px;
    border-radius: 6px;
}

.student-skylt-wrap .student-mini-add {
    min-width: 28px;
    padding: 2px 6px;
    font-size: 14px;
}

.student-skylt-wrap .student-upload-button {
    padding: 8px 10px;
    font-size: 13px;
}

.student-skylt-wrap .student-saved-item-actions .open,
.student-skylt-wrap .student-saved-item-actions .delete {
    min-width: 64px;
}

.student-decor-grid { display:none !important; flex-wrap:wrap; gap:8px; max-height:220px; overflow:auto; padding:6px; }
.student-decor-grid.show { display:flex !important; }
/* items hidden by default; JS will reveal matching items when folder selected */
.student-decor-grid .decor-item { display:none; width:80px; text-align:center; border:0; background:transparent; cursor:pointer; padding:4px; }
.student-decor-grid .decor-item img { width:72px; height:72px; object-fit:cover; border-radius:6px; display:block; margin:0 auto 6px; }
.student-decor-grid .decor-label { font-size:11px; color:#333; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.decor-folder-title { font-size:12px; font-weight:700; margin:8px 0 4px; }
.decor-folder-list { display:flex; gap:6px; flex-wrap:wrap; }