html, body {
    height: 100%;
    margin: 0;
}

.label-editor {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.label-editor {
    background: #ffffff;
    color: #111827;
    padding: 12px 16px 40px;
    font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

.label-editor .topbar {
    display: flex;
    justify-content: end;
    align-items: center;
    margin: 4px 0 14px;
}

.label-editor .tabs {
    display: flex;
    gap: 12px;
}

.label-editor .tab {
    background: #ffffff;
    color: #111827;
    border: 2px solid #d0d7de;
    border-radius: 12px;
    padding: 10px 18px;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, .03) inset;
    cursor: default;
}

.label-editor .tab.active {
    box-shadow: 0 0 0 2px rgba(37, 99, 235, .35) inset;
    color: #1d4ed8;
}

.label-editor .actions {
    display: flex;
    gap: 18px;
}

.label-editor .subheading {
    margin: 2px 0 10px;
    font-weight: 700;
    padding-left: 8px;
    color: #111827;
}

.label-editor .workspace {
    display: grid;
    grid-template-columns: 1fr minmax(260px, 420px);
    gap: 28px;
    align-items: stretch;
    width: 100%;
    max-width: none;
}

@media (max-width: 1100px) {
    .label-editor .workspace {
        grid-template-columns: 1fr;
    }

    .label-editor .right-rail {
        position: static;
        top: auto;
        max-height: none;
    }
}

/* canvas card */
.label-editor .canvas-card {
    border: 2px solid #d0d7de;
    border-radius: 16px;
    padding: 14px;
    position: relative;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    max-height: 80vh;
}

.label-editor .card-title {
    position: absolute;
    top: -12px;
    left: 14px;
    background: #ffffff;
    padding: 0 8px;
    font-weight: 700;
    color: #374151;
}

.label-editor .canvas-wrap {
    border: 2px solid #d0d7de;
    border-radius: 16px;
    padding: 22px;
    margin-top: 10px;
    background: #f9fafb;
    min-width: 0;
    max-width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.label-editor .hint-arrow.down {
    position: absolute;
    left: 8px;
    bottom: -4px;
}

.label-editor .hint-arrow.right {
    position: absolute;
    right: 24%;
    top: 50%;
}

/* right rail panels */
.label-editor .right-rail {
    display: flex;
    flex-direction: column;
    gap: 18px;
    height: 100%;
    align-self: stretch;
    width: 100%;
    max-width: 420px;
}

.label-editor .panel {
    border: 2px solid #d0d7de;
    border-radius: 16px;
    padding: 12px;
    background: #ffffff;
}

/* Make the first panel (variables) grow and allow internal scrolling */
.label-editor .right-rail .panel:first-child {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.label-editor .panel-title {
    position: relative;
    margin: 0 0 8px;
    font-size: 20px;
    font-weight: 800;
    color: #111827;
}

.label-editor .panel-note {
    margin-bottom: 10px;
    color: #6b7280;
}

.label-editor .parts-search {
    margin-bottom: 8px;
}

.label-editor .parts-search input {
    width: 100%;
    padding: 8px 10px;
    border: 2px solid #d0d7de;
    border-radius: 10px;
    background: #ffffff;
    color: #111827;
}

.label-editor .parts {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    overflow-y: auto;
}

.label-editor .parts .loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px 0;
}

.label-editor .pill {
    border: 2px solid #d0d7de;
    border-radius: 12px;
    padding: 8px 10px;
    background: #f9fafb;
    color: #374151;
}

.label-editor .field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 8px 0;
}

.label-editor .field-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin: 8px 0;
}

/* prevent text selection while interacting with canvas */
.label-editor .label-svg,
.label-editor .label-svg text,
.label-editor .draggable {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.label-editor label {
    color: #374151;
}

.label-editor .toggle {
    width: 54px;
    height: 28px;
    border: 2px solid #d0d7de;
    border-radius: 16px;
    position: relative;
    background: #f3f4f6;
}

.label-editor .toggle span {
    position: absolute;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #9ca3af;
    top: 1px;
    left: 1px;
}

.label-editor .grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 14px;
    min-width: 0;
}

@media (max-width: 800px) {
    .label-editor .grid-2 {
        grid-template-columns: 1fr;
    }
}

.label-editor .grid-2 > * {
    min-width: 0;
}

/* canvas internals */
.label-editor .canvas-outer {
    background: #ddd;
    position: relative;
    border: 2px solid #d0d7de;
    border-radius: 5px;
    overscroll-behavior: contain;
    min-height: 50vh;
    overflow: hidden;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    padding: 6px;
    -ms-overflow-style: none;
    scrollbar-width: none;
    min-width: 0;
    max-width: 100%;
    flex: 1 1 auto;
    touch-action: none;
}

.label-editor .canvas-outer::-webkit-scrollbar {
    display: none;
}

.label-editor .canvas-outer.pannable {
    cursor: grab;
}

.label-editor .canvas-outer.panning {
    cursor: grabbing;
}

.label-editor .zoom-outer {
    transition: none;
    min-width: 0;
    max-width: 100%;
}

.label-editor .zoom-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: flex-end;
    margin-bottom: 8px;
}

@media (max-width: 700px) {
    .label-editor .zoom-controls {
        flex-wrap: wrap;
        justify-content: center;
        row-gap: 8px;
    }
}

.label-editor .zoom-controls button {
    background: #ffffff;
    color: #111827;
    border: 2px solid #d0d7de;
    border-radius: 10px;
    padding: 4px 10px;
}

/* rulers */
.label-editor .canvas-outer .ruler {
    position: absolute;
    left: 0;
    top: 0;
    pointer-events: none;
    color: #000;
    font-size: 10px;
    z-index: 1;
}

.label-editor .canvas-outer .ruler-top {
    right: 0;
    height: 32px;
    border-bottom: 1px solid #e5e7eb;
    background: linear-gradient(to bottom, #f9fafb, #ffffff);
}

.label-editor .canvas-outer .ruler-left {
    bottom: 0;
    width: 64px;
    border-right: 1px solid #e5e7eb;
    background: linear-gradient(to right, #f9fafb, #ffffff);
}

.label-editor .canvas-outer .ruler .tick {
    position: absolute;
}

.label-editor .canvas-outer .ruler-top .tick {
    bottom: 0;
    width: 0;
    border-left: 1px solid #d1d5db;
    height: 8px;
}

.label-editor .canvas-outer .ruler-top .tick.major {
    height: 12px;
    border-color: #9ca3af;
}

.label-editor .canvas-outer .ruler-top .tick span {
    position: absolute;
    bottom: 12px;
    left: 2px;
    transform: translateX(-50%);
    font-size: 10px;
    color: #000;
}

.label-editor .canvas-outer .ruler-left .tick {
    right: 0;
    height: 0;
    border-top: 1px solid #d1d5db;
    width: 8px;
}

.label-editor .canvas-outer .ruler-left .tick.major {
    width: 12px;
    border-color: #9ca3af;
}

.label-editor .canvas-outer .ruler-left .tick span {
    position: absolute;
    right: 14px;
    top: -6px;
    font-size: 10px;
    color: #000;
}

.label-editor .etikett-wrap {
    position: relative;
    background: #ffffff;
    box-shadow: 0 0 0 2px #e5e7eb inset;
}

.label-editor .label-svg {
    display: block;
    width: 100%;
    height: 100%;
}

/* wrapper resize handles (edges & corners) */
.label-editor .etikett-wrap .resize-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(59, 130, 246, 0.4);
    border-radius: 3px;
    z-index: 2;
}

.label-editor .etikett-wrap .handle-n {
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    cursor: n-resize;
}

.label-editor .etikett-wrap .handle-s {
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    cursor: s-resize;
}

.label-editor .etikett-wrap .handle-e {
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    cursor: e-resize;
}

.label-editor .etikett-wrap .handle-w {
    left: -6px;
    top: 50%;
    transform: translateY(-50%);
    cursor: w-resize;
}

.label-editor .etikett-wrap .handle-ne {
    top: -7px;
    right: -7px;
    width: 14px;
    height: 14px;
    cursor: ne-resize;
}

.label-editor .etikett-wrap .handle-nw {
    top: -7px;
    left: -7px;
    width: 14px;
    height: 14px;
    cursor: nw-resize;
}

.label-editor .etikett-wrap .handle-se {
    bottom: -7px;
    right: -7px;
    width: 14px;
    height: 14px;
    cursor: se-resize;
}

.label-editor .etikett-wrap .handle-sw {
    bottom: -7px;
    left: -7px;
    width: 14px;
    height: 14px;
    cursor: sw-resize;
}

/* selected item highlight */
.label-editor .draggable.selected .resize-guide {
    stroke: #3b82f6;
    stroke-width: 2;
    stroke-dasharray: none;
}

/* cursor behavior: always show move cursor unless item is selected */
.label-editor .draggable:not(.selected),
.label-editor .draggable:not(.selected) *,
.label-editor .label-svg .draggable:not(.selected) {
    cursor: move !important;
}

/* simple modal styles for preview/product picker */
.pswc-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.pswc-modal {
    background: #fff;
    border-radius: 12px;
    border: 2px solid #d0d7de;
    width: 560px;
    max-width: 92vw;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
}

.pswc-modal.pswc-modal-large {
    width: 960px;
    max-width: 96vw;
}

.pswc-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid #e5e7eb;
}

.pswc-modal-body {
    padding: 12px;
}

.pswc-input {
    width: 100%;
    padding: 8px 10px;
    border: 2px solid #d0d7de;
    border-radius: 10px;
}

.pswc-list {
    margin-top: 10px;
    max-height: 50vh;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pswc-list-item {
    text-align: left;
    border: 2px solid #d0d7de;
    border-radius: 10px;
    padding: 10px;
    background: #f9fafb;
    cursor: pointer;
}

.pswc-list-item:hover {
    background: #f3f4f6;
}

.pswc-title {
    font-weight: 600;
    color: #111827;
}

.pswc-sub {
    font-size: 12px;
    color: #6b7280;
}

.pswc-empty {
    padding: 16px;
    color: #6b7280;
}

.pswc-text-editor-field {
    position: relative;
}

.pswc-autocomplete {
    position: absolute;
    z-index: 20;
    border: 1px solid #c7d2da;
    border-radius: 8px;
    background: #1f2933;
    box-shadow: 0 14px 28px rgba(15, 23, 42, 0.22);
    overflow-x: hidden;
    overflow-y: auto;
}

.pswc-autocomplete-item {
    width: 100%;
    display: flex;
    align-items: center;
    padding: 7px 10px;
    border: 0;
    border-top: 1px solid rgba(148, 163, 184, 0.16);
    background: transparent;
    color: #e5eef5;
    text-align: left;
    cursor: pointer;
    font: inherit;
}

.pswc-autocomplete-item:first-child {
    border-top: 0;
}

.pswc-autocomplete-item:hover,
.pswc-autocomplete-item.is-active {
    background: linear-gradient(90deg, rgba(56, 189, 248, 0.22), rgba(14, 165, 233, 0.08));
    color: #f8fafc;
}

.pswc-autocomplete-label {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 12px;
}
