/* ================================================
   EZ4ME Enhanced Styles - Modern Polish Edition
   Original Design Preserved with Modern Enhancements
   ================================================ */

/* ================================================
   Design Tokens - Proportions & Guide Lines
   ================================================ */
:root {
    /* Spacing scale (4px grid) */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 12px;
    --space-lg: 16px;
    --space-xl: 20px;
    --space-2xl: 24px;
    --space-3xl: 32px;
    --space-4xl: 40px;
    
    /* Component heights (4px grid) */
    --input-h-sm: 32px;
    --input-h: 36px;
    --input-h-lg: 40px;
    --btn-h-sm: 32px;
    --btn-h: 36px;
    --btn-h-lg: 44px;
    --header-h: 80px;
    
    /* Drawer canvas & containers - human-sized, consistent */
    --drawer-canvas-min-h: 560px;
    --drawer-canvas-padding: 16px;
    --canvas-area-min-h: 400px;
    /* Elements basket — wider panel, taller scroll (aligned with larger elements canvas) */
    --panel-side-width: 340px;
    --panel-list-max-h: 400px;
    --code-block-max-h: 360px;
    
    /* Typography scale */
    --text-xs: 11px;
    --text-sm: 12px;
    --text-base: 14px;
    --text-md: 16px;
    --text-lg: 18px;
    --text-xl: 20px;
    --text-2xl: 24px;
    --text-3xl: 28px;
    
    /* Border radius (4px grid) */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 10px;
    --radius-xl: 12px;
    --radius-2xl: 16px;
    
    /* Borders */
    --border-1: 1px;
    --border-2: 2px;
    --border-3: 3px;
    
    /* Animation timing */
    --ease-micro: 0.15s ease;
    --ease-fast: 0.2s ease;
    --ease-normal: 0.25s ease;
    --ease-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base Styles */
h6{page-break-before: always;}
html, body{height: 100%;}
html {
    display: table;
    margin: auto;
}
body {
    display: table-cell;
    vertical-align: middle;
    padding: 0px;
    margin: 0px;
    font-size: 16px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #2c3e50;
    background-color: antiquewhite;
    background-image: url('../Images/BodyBG.png');
    background-position: top center;
    background-repeat: repeat;
    background-attachment: fixed;
}

/* Smooth Transitions */
* {
    box-sizing: border-box;
}

input, button, select {
    transition: all var(--ease-smooth);
}

/* Enhanced Input Fields */
input[type="text"], input[type="number"], select {
    border: 2px solid #e0e0e0;
    border-radius: var(--radius-md);
    padding: 8px 12px;
    font-size: var(--text-md);
    outline: none;
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

input[type="text"]:focus, input[type="number"]:focus, select:focus {
    border-color: #5381B7;
    box-shadow: 0 0 0 3px rgba(83, 129, 183, 0.15), 0 4px 8px rgba(0,0,0,0.1);
    transform: translateY(-1px);
}

input[type="text"]:hover, input[type="number"]:hover, select:hover {
    border-color: #b0b0b0;
    box-shadow: 0 3px 6px rgba(0,0,0,0.08);
}

/* Enhanced Buttons */
.Button, input[type="button"] {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-weight: 600;
    font-size: var(--text-md);
    color: white;
    background: linear-gradient(135deg, #5381B7 0%, #4a73a5 100%);
    border: none;
    border-radius: var(--radius-lg);
    padding: 12px 24px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(83, 129, 183, 0.3);
    position: relative;
    overflow: hidden;
}

.Button:hover, input[type="button"]:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(83, 129, 183, 0.4);
    background: linear-gradient(135deg, #5f8dc9 0%, #5381B7 100%);
}

.Button:active, input[type="button"]:active {
    transform: translateY(0px);
    box-shadow: 0 2px 8px rgba(83, 129, 183, 0.3);
}

.ButtonSave {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-weight: 600;
    font-size: 16px;
    color: white;
    background: linear-gradient(135deg, #003c68 0%, #002847 100%);
    border: none;
    border-radius: 10px;
    padding: 12px 24px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 60, 104, 0.3);
}

.ButtonSave:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 60, 104, 0.4);
    background: linear-gradient(135deg, #004878 0%, #003c68 100%);
}

.LogoDiv {
    padding-top: 10px;
    text-align: center;
}

/* Enhanced Menu Items */
.MenuTD {
    vertical-align: top;
    background-image: url('../Images/Menu/Menu_Drawer_Down.png');
    background-size: 100% 60px;
    background-repeat: no-repeat;
    background-position: center bottom;
    padding: 24px 8px 0px 8px;
    margin: 0px;
    transition: all var(--ease-smooth);
    position: relative;
}

.MenuTD:hover {
    transform: translateY(-2px);
    filter: brightness(1.05);
}

.MenuTD::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, #343089, transparent);
    transition: width var(--ease-smooth);
}

.MenuTD:hover::after {
    width: 80%;
}

.MenuTD A:link, .MenuTD A:visited, .MenuTD A:hover {
    font-size: 14px;
    color: #343089;
    text-decoration: none;
    width: 100%;
    height: 100%;
    display: block;
    transition: color var(--ease-smooth);
}

.MenuTD:hover A {
    color: #5381B7;
}

.MenuTDSelected {
    vertical-align: top;
    background-image: url('../Images/Menu/Menu_Drawer_Up.png');
    background-size: 100% 60px;
    background-repeat: no-repeat;
    background-position: center bottom;
    padding: 16px 8px 0px 8px;
    margin: 0px;
    animation: drawerPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes drawerPop {
    0% { transform: translateY(6px); opacity: 0.9; }
    100% { transform: translateY(0); opacity: 1; }
}

.MenuTDSelected A:link, .MenuTDSelected A:visited, .MenuTDSelected A:hover {
    font-size: 14px;
    font-weight: bold;
    color: #343089;
    text-decoration: none;
    width: 100%;
    height: 100%;
    display: block;
}

.SubMenuTD {
    height: 32px;
    vertical-align: top;
    border-top: 1px solid white;
    border-left: 1px solid white;
    border-bottom: 1px solid grey;
    border-right: 1px solid grey;
    padding: 0px 10px 0px 10px;
    margin: 0px;
    transition: all 0.2s ease;
}

.SubMenuTD:hover {
    background-color: rgba(83, 129, 183, 0.05);
    border-color: #5381B7;
}

.SubMenuTD A:link, .SubMenuTD A:visited, .SubMenuTD A:hover {
    font-size: 14px;
    color: #343089;
    text-decoration: none;
    width: 100%;
    height: 100%;
    display: block;
}

.CategoryA:link, .CategoryA:visited, .CategoryA:hover {
    white-space: nowrap;
    font-size: 18px;
    color: #343089;
    text-decoration: none;
    transition: color 0.3s ease;
}

.CategoryA:hover {
    color: #5381B7;
}

.SubMenuTDSelected {
    height: 32px;
    vertical-align: top;
    border-top: 2px solid grey;
    border-left: 2px solid grey;
    border-bottom: 2px solid white;
    border-right: 2px solid white;
    padding: 0px 10px 0px 10px;
    margin: 0px;
    background-color: rgba(83, 129, 183, 0.1);
}

.SubMenuTDSelected A:link, .SubMenuTDSelected A:visited, .SubMenuTDSelected A:hover {
    font-size: 14px;
    font-weight: bold;
    color: #343089;
    text-decoration: none;
    width: 100%;
    height: 100%;
    display: block;
}

.SubMenuNoBorderTD {
    height: 32px;
    vertical-align: top;
    padding: 0px 10px 0px 10px;
    margin: 0px;
}

.SubMenuNoBorderTD A:link, .SubMenuNoBorderTD A:visited, .SubMenuNoBorderTD A:hover {
    font-size: 14px;
    color: #343089;
    text-decoration: none;
    width: 100%;
    height: 100%;
    display: block;
}

.PageNumberDiv {
    height: 50px;
    width: 716px;
    font-size: 20px;
    font-weight: bold;
    color: white;
    text-align: center;
    background: linear-gradient(135deg, #666 0%, #888 100%);
    padding-top: 15px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.PageNumberDivLast {
    height: 32px;
    width: 716px;
    font-size: 20px;
    font-weight: bold;
    color: white;
    text-align: center;
    background: linear-gradient(135deg, #666 0%, #888 100%);
    padding-top: 15px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.delete-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 10px 20px;
    background: white;
    border: 2px solid #ffcdd2;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: var(--text-base);
    transition: all var(--ease-smooth);
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.delete-btn:hover {
    background: #ffebee;
    border-color: #ef5350;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239, 83, 80, 0.2);
}

.delete-btn:active {
    transform: translateY(0);
}

.delete-icon {
    width: 18px;
    height: 18px;
    fill: #e53935;
    transition: transform var(--ease-smooth);
}

.delete-btn:hover .delete-icon {
    transform: rotate(90deg);
}

/* Drawer Designer Enhanced Styles */
.drawer-designer-header {
    background-image: url('../Images/HeaderBG.jpg');
    background-size: cover;
    background-position: top center;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    box-shadow: 0 4px 20px rgba(52, 48, 137, 0.3);
    animation: fadeInDown 0.35s ease-out;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Drawer action buttons - consistent min-width (human, not stretched) */
.drawer-action-btn {
    min-width: 96px;
    height: 36px;
}

/* ── Multi-drawer tabs: soft chrome, gentle motion ── */
.drawer-tabs-bar {
    display: inline-block;
    background: linear-gradient(155deg, #7d6358 0%, #5a463c 100%);
    padding: 14px 18px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow:
        0 2px 14px rgba(40, 28, 20, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.drawer-tabs-toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.drawer-tabs-strip {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    max-width: min(920px, calc(100vw - 220px));
    justify-content: center;
}

.drawer-tab {
    position: relative;
    min-width: 120px;
    padding: 10px 16px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 2px solid transparent;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
    transition:
        transform var(--ease-smooth),
        box-shadow var(--ease-smooth),
        background var(--ease-smooth),
        border-color var(--ease-smooth),
        color var(--ease-smooth);
}

.drawer-tab:hover {
    background: rgba(255, 255, 255, 0.24);
    transform: translateY(-0.5px);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.14);
}

.drawer-tab.active {
    background: linear-gradient(145deg, #fffefb 0%, #f3f0ec 100%);
    color: #4e3d35;
    font-weight: 700;
    border-color: rgba(141, 110, 99, 0.65);
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.12);
}

.drawer-tab:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.45), 0 3px 12px rgba(0, 0, 0, 0.12);
}

.drawer-tab-icon {
    font-size: 18px;
    line-height: 1;
}

.drawer-tab-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 90px;
}

.drawer-tab-delete {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 22px;
    height: 22px;
    min-width: 22px;
    min-height: 22px;
    padding: 0;
    border-radius: 50%;
    background: #e57373;
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.18);
    transition: transform var(--ease-smooth), background var(--ease-smooth), box-shadow var(--ease-smooth);
}

.drawer-tab-delete:hover {
    transform: scale(1.08);
    background: #ef5350;
}

.drawer-tab-delete:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px rgba(244, 67, 54, 0.6);
}

@keyframes drawerTabFlash {
    0% {
        box-shadow: 0 0 0 0 rgba(129, 199, 132, 0.45);
        transform: scale(1);
    }
    45% {
        box-shadow: 0 0 0 5px rgba(129, 199, 132, 0.22);
        transform: scale(1.008);
    }
    100% {
        box-shadow: 0 3px 14px rgba(0, 0, 0, 0.12);
        transform: scale(1);
    }
}

.drawer-tab.drawer-tab--flash {
    animation: drawerTabFlash 0.7s cubic-bezier(0.33, 1, 0.68, 1);
}

.btn-add-drawer {
    transition: transform var(--ease-smooth), box-shadow var(--ease-smooth), filter var(--ease-smooth);
}

.btn-add-drawer:hover {
    filter: brightness(1.03);
    box-shadow: 0 3px 12px rgba(76, 175, 80, 0.32);
}

.btn-add-drawer:active {
    transform: scale(0.99);
}

.btn-add-drawer:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px rgba(200, 230, 201, 0.9), 0 2px 10px rgba(76, 175, 80, 0.35);
}

@media (max-width: 640px) {
    .drawer-tabs-strip {
        max-width: 100%;
        justify-content: flex-start;
    }
}

/* Secondary/panel buttons - aligned */
.btn-panel {
    height: 36px;
    padding: 0 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.drawer-canvas {
    background: white;
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    transition: box-shadow var(--ease-smooth);
}

.drawer-canvas:hover {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

/* Icon Buttons Enhanced */
input[type="button"][title="Delete"],
input[type="button"][title="Full Screen"] {
    border: 2px solid rgba(255, 255, 255, 0.3);
    transition: all var(--ease-smooth);
    cursor: pointer;
}

input[type="button"][title="Delete"]:hover {
    background-color: rgba(239, 83, 80, 0.2);
    border-color: #ef5350;
    transform: scale(1.05) rotate(90deg);
}

input[type="button"][title="Full Screen"]:hover {
    background-color: rgba(83, 129, 183, 0.2);
    border-color: #5381B7;
    transform: scale(1.05);
}

/* Loading Animation */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.loading {
    animation: pulse 1.5s ease-in-out infinite;
}

/* Smooth Scroll */
html {
    scroll-behavior: smooth;
}

/* Image Hover Effects */
img {
    transition: transform var(--ease-smooth);
}

a:hover img {
    transform: scale(1.02);
}

/* ================================================
   Global Header & Panel Headers
   ================================================ */

.global-header {
    min-height: var(--header-h);
}

.global-header .header-spacer {
    width: 100%;
    height: var(--header-h);
    display: block;
    object-fit: cover;
    max-width: 100%;
}

.header-logo {
    max-width: 180px;
    height: auto;
    display: block;
}

.panel-header {
    background-image: url('../Images/HeaderBG.jpg');
    background-position: top center;
    background-repeat: repeat-x;
    background-size: cover;
    color: white;
    padding: var(--space-xl) var(--space-3xl);
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    text-align: center;
    transition: box-shadow var(--ease-smooth);
}

.panel-header .panel-header__title {
    font-size: var(--text-3xl);
    font-weight: 700;
    margin-bottom: var(--space-sm);
    line-height: 1.2;
}

.panel-header .panel-header__subtitle {
    font-size: var(--text-base);
    opacity: 0.9;
}

.panel-header--no-radius {
    border-radius: 0;
}

/* ================================================
   Guide Lines - Cards, Borders, Gaps
   ================================================ */

.card-content {
    background: white;
    border-radius: 0 0 var(--radius-2xl) var(--radius-2xl);
    padding: var(--space-4xl);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.card-content--flat {
    border-radius: 0;
}

.guide-border {
    border: 1px solid #e9ecef;
}

.guide-border--strong {
    border: 2px solid #e0e0e0;
}

/* Header Enhancement */
.MenuTop {
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.05);
}

/* Select Dropdown Enhancement */
select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23343089' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 35px;
}

/* ================================================
   Layout & Visibility Fixes
   ================================================ */

/* Fix drawer canvas stacking - use display instead of visibility */
.drawer-canvas {
    position: absolute;
    top: 0;
    left: 0;
    display: none;
}

.drawer-canvas.active,
.drawer-canvas[style*="visibility:visible"],
.drawer-canvas[style*="visibility: visible"] {
    display: block !important;
    position: relative;
}

/* Fix for inline visibility styles - override with proper display */
#Div_D1T1, #Div_D1T2, #Div_D1T3, #Div_D1T4, #Div_D1T5, #Div_D1T6 {
    position: relative;
}

/* Unified canvas stage size - human, consistent across all tabs */
#Div_D1T2, #Div_D1T3, #Div_D1T4, #Div_D1T5 {
    min-height: min(var(--drawer-canvas-min-h), calc(100vh - 380px)) !important;
    padding: var(--drawer-canvas-padding) !important;
}

/* Elements diagram tab — stage height + row stretches with tall canvas (parity with line tab) */
#Div_D1T3.elements-diagram-stage {
    min-height: min(calc(var(--drawer-canvas-min-h) + 140px), calc(100vh - 300px)) !important;
}

#Div_D1T3 .elements-diagram-row {
    display: flex;
    align-items: stretch;
    gap: var(--space-4);
    min-height: min(560px, calc(100vh - 420px));
}

#Div_D1T3 .elements-canvas-column {
    display: flex;
    flex-direction: column;
}

#Div_D1T3 .elements-canvas-area.canvas-area {
    flex: 1 1 auto;
    min-height: min(520px, calc(100vh - 440px));
    align-items: flex-start;
    justify-content: flex-start;
}

#Div_D1T3 .elements-canvas-wrapper {
    max-width: 100%;
    overflow: auto;
}

#Div_D1T3 .elements-preview-canvas {
    display: block;
}

#Div_D1T3 .basket-panel.drawer-panel-side {
    width: min(var(--panel-side-width), 38vw);
    min-width: 280px;
    display: flex;
    flex-direction: column;
    align-self: stretch;
}

#Div_D1T3 .basket-card-shell {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#Div_D1T3 .basket-card-shell .drawer-panel-list {
    flex: 1 1 auto;
    max-height: min(520px, calc(100vh - 340px));
    min-height: 260px;
    padding: var(--space-3) var(--space-4);
}

/* Line diagram tab: calmer pan/scroll — no scroll chaining to the page while exploring */
#Div_D1T2 {
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* Line canvas: browser gestures don’t steal drawing/touch (parent still scrolls when not on canvas) */
#lineDrawingCanvas,
.line-drawing-canvas-el {
    touch-action: none;
}

/* Line diagram tab — soft stage (replaces heavy inline shadow) */
.line-diagram-stage {
    width: 100%;
    background: linear-gradient(160deg, #f8fafc 0%, #eef2f6 52%, #e9eef3 100%);
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.75),
        0 1px 10px rgba(15, 23, 42, 0.05);
}

/* Drawing surface — wood tone, lighter frame, calm depth */
.line-drawing-canvas-el {
    background: #fff;
    border-radius: 12px;
    border: 2px solid #a67c52;
    box-shadow:
        0 4px 22px rgba(15, 23, 42, 0.07),
        0 1px 3px rgba(15, 23, 42, 0.05);
    transition: box-shadow var(--ease-smooth), border-color var(--ease-smooth);
}

.canvas-wrapper:hover .line-drawing-canvas-el {
    border-color: #8d6e63;
    box-shadow:
        0 6px 26px rgba(15, 23, 42, 0.09),
        0 2px 6px rgba(15, 23, 42, 0.05);
}

/* Side panel & list - aligned sizes */
.drawer-panel-side {
    width: var(--panel-side-width);
    flex-shrink: 0;
}
.drawer-panel-list {
    max-height: var(--panel-list-max-h);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.drawer-code-block {
    max-height: var(--code-block-max-h);
    overflow: auto;
}

/* Canvas area - consistent min height across tabs */
.canvas-area {
    min-height: var(--canvas-area-min-h);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Canvas wrapper - overlays positioned relative to canvas, not full area */
.canvas-wrapper {
    position: relative;
    display: inline-block;
}

.canvas-overlay {
    position: absolute;
    bottom: 12px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    /* Let mouse events reach the canvas below — avoids cancelling a line when hovering the overlay */
    pointer-events: none;
}

/* Canvas toolbar - buttons aligned, consistent gap */
.canvas-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 12px;
}

/* Fix tab container */
.drawer-tabs-content {
    position: relative;
    min-height: min(var(--drawer-canvas-min-h), calc(100vh - 380px));
}

/* ================================================
   Spacing & Proportion Fixes
   ================================================ */

/* Content max-width: human-normal, not stretched (1100-1200px) */
.content-max {
    max-width: min(1200px, calc(100vw - 48px));
    margin-left: auto;
    margin-right: auto;
    padding-left: 24px;
    padding-right: 24px;
    width: 100%;
    box-sizing: border-box;
}

/* Fix excessive spacing in tables */
table.MenuTop {
    margin: 0 auto;
    table-layout: fixed;
    width: 100%;
}

table.MenuTop td {
    vertical-align: bottom;
}

/* Fix spacer images - limit their impact */
img[src*="t.gif"] {
    max-width: 60px;
    height: auto !important;
}

/* Fix header inputs spacing */
.drawer-designer-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    padding: var(--space-lg) var(--space-xl) !important;
    min-height: 64px;
    height: auto !important;
}

.drawer-designer-header label {
    white-space: nowrap;
}

.drawer-designer-header input[type="text"],
.drawer-designer-header input[type="number"] {
    width: auto;
    min-width: 60px;
    max-width: 200px;
}

/* Dimension stepper: hide native spinners, custom arrows above */
.dimension-stepper input[type="number"]::-webkit-outer-spin-button,
.dimension-stepper input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.dimension-stepper .stepper-btn:hover {
    background: rgba(139,69,19,0.15) !important;
}

/* Fix button row spacing */
.drawer-designer-header input[type="button"] {
    flex-shrink: 0;
}

/* ================================================
   Menu Tab Fixes
   ================================================ */

/* Icon + label as one tight group (flex, not split table cells) */
.MenuTD A.drawer-tab-link,
.MenuTDSelected A.drawer-tab-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    box-sizing: border-box;
}

.MenuTD .drawer-tab-emoji,
.MenuTDSelected .drawer-tab-emoji {
    font-size: 22px;
    line-height: 1;
    flex-shrink: 0;
}

.MenuTD .drawer-tab-label,
.MenuTDSelected .drawer-tab-label {
    text-align: center;
    font-weight: 600;
    font-size: 12px;
    line-height: 1.25;
}

/* Legacy: nested table tabs if any remain */
.MenuTD table,
.MenuTDSelected table {
    width: 100%;
    table-layout: fixed;
}

.MenuTD table td,
.MenuTDSelected table td {
    vertical-align: middle;
}

.MenuTD table td:first-child,
.MenuTDSelected table td:first-child {
    width: 40px !important;
    text-align: center;
}

/* Items basket — collapsible sections */
details.basket-section-acc {
    border-bottom: 1px solid #e9ecef;
}

details.basket-section-acc > summary.basket-section-acc-summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: #f8f9fa;
    font-weight: 700;
    font-size: 14px;
    color: #2c3e50;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid #dee2e6;
}

details.basket-section-acc > summary::-webkit-details-marker {
    display: none;
}

details.basket-section-acc[open] > summary .basket-acc-arrow {
    transform: rotate(90deg);
}

.basket-acc-arrow {
    display: inline-block;
    font-size: 10px;
    line-height: 1;
    transition: transform 0.2s ease;
    width: 14px;
    flex-shrink: 0;
}

details.basket-section-acc + details.basket-section-acc {
    margin-top: 10px;
}

/* ================================================
   Responsive Enhancements
   ================================================ */

@media (max-width: 1200px) {
    .drawer-designer-header {
        padding: 12px 15px !important;
    }
    
    .drawer-designer-header input[type="text"] {
        width: 150px !important;
    }
    
    .drawer-designer-header input[type="number"] {
        width: 50px !important;
    }
}

@media (max-width: 768px) {
    body {
        font-size: 16px;
    }
    
    .MenuTD, .MenuTDSelected {
        padding: 15px 5px 0px 5px;
    }
    
    .MenuTD .drawer-tab-emoji,
    .MenuTDSelected .drawer-tab-emoji {
        font-size: 20px !important;
    }
    
    .MenuTD .drawer-tab-label,
    .MenuTDSelected .drawer-tab-label {
        font-size: 11px !important;
        line-height: 1.2 !important;
    }

    .MenuTD table td:first-child,
    .MenuTDSelected table td:first-child {
        font-size: 20px !important;
        padding: 0 3px !important;
    }
    
    .MenuTD table td:last-child,
    .MenuTDSelected table td:last-child {
        font-size: 11px !important;
        line-height: 1.2 !important;
    }
    
    input[type="text"], input[type="number"] {
        font-size: 14px;
    }
    
    /* Fix drawer header on mobile */
    .drawer-designer-header {
        flex-direction: column;
        gap: var(--space-sm);
        padding: var(--space-lg) !important;
    }
    
    .drawer-designer-header > * {
        width: 100%;
        text-align: center;
    }
    
    .drawer-designer-header input[type="text"],
    .drawer-designer-header input[type="number"] {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    /* Hide spacers on mobile */
    img[src*="t.gif"][width="60"],
    img[src*="t.gif"][width="40"] {
        width: 10px !important;
    }
}

@media (max-width: 480px) {
    .MenuTD, .MenuTDSelected {
        padding: 10px 3px 0px 3px;
    }
    
    .MenuTD .drawer-tab-emoji,
    .MenuTDSelected .drawer-tab-emoji {
        font-size: 18px !important;
    }
    
    .MenuTD .drawer-tab-label,
    .MenuTDSelected .drawer-tab-label {
        font-size: 10px !important;
    }
    
    .MenuTD table td:first-child,
    .MenuTDSelected table td:first-child {
        font-size: 18px !important;
        width: 30px !important;
    }
    
    .MenuTD table td:last-child,
    .MenuTDSelected table td:last-child {
        font-size: 10px !important;
    }
    
    .drawer-canvas {
        height: auto !important;
        min-height: 400px;
        padding: 10px !important;
    }
}
