* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    height: 100vh;
    overflow: hidden;
    background: #1e1e1e;
    color: #e0e0e0;
}

/* TOP BAR */
#topBar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: #2d2d30;
    border-bottom: 1px solid #3e3e42;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.top-left h1 {
    font-size: 18px;
    font-weight: 600;
    color: #fff;
    margin: 0;
}

.top-center {
    display: flex;
    align-items: center;
    gap: 12px;
}

.top-right {
    display: flex;
    gap: 10px;
    align-items: center;
}

.tool-group {
    display: flex;
    gap: 4px;
    background: #3e3e42;
    border-radius: 6px;
    padding: 4px;
}

.tool-divider {
    width: 1px;
    height: 30px;
    background: #555;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: #e0e0e0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.icon-btn:hover:not(:disabled) {
    background: #505050;
}

.icon-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.tool-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border: none;
    background: transparent;
    color: #e0e0e0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

.tool-btn:hover:not(:disabled) {
    background: #505050;
}

.tool-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.tool-btn.active {
    background: #0e639c;
    color: #fff;
}

.tool-btn svg {
    stroke: currentColor;
}

.primary-btn {
    padding: 8px 16px;
    border: none;
    background: #0e639c;
    color: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s;
}

.primary-btn:hover:not(:disabled) {
    background: #1177bb;
}

.primary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* FLOATING HELP BUTTON */
.floating-help-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: #0e639c;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
    z-index: 999;
}

.floating-help-btn:hover {
    background: #1177bb;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.floating-help-btn:active {
    transform: scale(1.05);
}

.floating-help-btn svg {
    stroke: currentColor;
}

/* COLLAPSE BUTTONS */
.collapse-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 48px;
    background: #3e3e42;
    border: 1px solid #555;
    color: #999;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    transition: all 0.3s ease;
    border-radius: 0;
}

.collapse-btn:hover {
    background: #505050;
    color: #fff;
}

.collapse-btn svg {
    transition: transform 0.3s ease;
}

.collapse-left {
    border-left: none;
    border-radius: 0 4px 4px 0;
}

.collapse-right {
    border-right: none;
    border-radius: 4px 0 0 4px;
}

/* EXPORT DROPDOWN */
.export-dropdown {
    position: relative;
    display: inline-block;
}

.export-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: #2d2d30;
    border: 1px solid #3e3e42;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    min-width: 180px;
    display: none;
    z-index: 1001;
    overflow: hidden;
}

.export-dropdown.open .export-dropdown-menu {
    display: block;
}

.export-option {
    display: block;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: #e0e0e0;
    text-align: left;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
    border-bottom: 1px solid #3e3e42;
}

.export-option:last-child {
    border-bottom: none;
}

.export-option:hover {
    background: #3e3e42;
}

.export-option:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* MAIN CONTENT */
#mainContent {
    display: flex;
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
}

/* LEFT SIDEBAR */
#leftSidebar {
    width: 200px;
    background: #252526;
    border-right: 1px solid #3e3e42;
    overflow-y: auto;
    overflow-x: visible;
    flex-shrink: 0;
    position: relative;
    transition: margin-left 0.3s ease;
}

#leftSidebar.collapsed {
    margin-left: -200px;
}

#leftSidebar .collapse-btn {
    right: -25px;
    position: fixed; 
    left: 200px;
}

#leftSidebar.collapsed .collapse-btn {
    left: 0px;
}

#leftSidebar.collapsed .collapse-btn svg {
    transform: rotate(180deg);
}

.sidebar-section {
    padding: 16px;
    border-bottom: 1px solid #3e3e42;
}

.sidebar-section:last-child {
    border-bottom: none;
}

.sidebar-section h3 {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: #999;
    margin-bottom: 12px;
    letter-spacing: 0.5px;
}

#pageControls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.page-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.page-buttons .secondary-btn,
.page-buttons .danger-btn {
    padding: 6px 8px;
    font-size: 11px;
}

#historyLog {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.history-item {
    padding: 8px 10px;
    background: #2d2d30;
    border: 1px solid #3e3e42;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.history-item:hover {
    background: #37373d;
    border-color: #505050;
}

.history-item.current {
    background: #094771;
    border-color: #0e639c;
}

.history-item .action-type {
    color: #ccc;
    font-size: 11px;
    font-weight: 500;
}

.history-item .timestamp {
    color: #888;
    font-size: 10px;
    margin-top: 2px;
}

/* CENTER AREA */
#centerArea {
    flex: 1;
    overflow: auto;
    background: #1e1e1e;
    position: relative;
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20"><rect width="10" height="10" fill="%232a2a2a"/><rect x="10" y="10" width="10" height="10" fill="%232a2a2a"/></svg>');
}

#canvasContainer {
    position: relative;
    min-width: 100%;
    min-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#emptyState {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #999;
    max-width: 400px;
    padding: 40px;
}

#emptyState h2 {
    font-size: 24px;
    margin-bottom: 16px;
    color: #ccc;
}

#emptyState p {
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 24px;
}

#emptyState button {
    padding: 12px 24px;
    font-size: 14px;
}

#canvasWrapper {
    position: relative;
    display: inline-block;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    vertical-align: top;
    transform-origin: 0 0;
    z-index: 1;
}

#imageCanvas, #editCanvas {
    position: absolute;
    left: 0;
    top: 0;
}

#imageCanvas {
    pointer-events: none;
}

#editCanvas {
    pointer-events: auto;
}

/* BRUSH CURSOR */
#brushCursor {
    position: fixed;
    border: 2px solid rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    pointer-events: none;
    display: none;
    transform: translate(-50%, -50%);
    z-index: 1000;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5), 
                inset 0 0 0 1px rgba(0, 0, 0, 0.5);
}

/* RIGHT SIDEBAR */
#rightSidebar {
    width: 300px;
    background: #252526;
    border-left: 1px solid #3e3e42;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: relative;
    transition: margin-right 0.3s ease;
}

#rightSidebar.collapsed {
    margin-right: -300px;
}

#rightSidebar .collapse-btn {
    left: -25px;
    position: fixed; 
    right: 300px; 
    left: auto;
}

#rightSidebar.collapsed .collapse-btn {
    right: 0px;
}

#rightSidebar.collapsed .collapse-btn svg {
    transform: rotate(180deg);
}

/* TABS */
.tabs {
    display: flex;
    background: #2d2d30;
    border-bottom: 1px solid #3e3e42;
}

.tab-btn {
    flex: 1;
    padding: 12px 16px;
    border: none;
    background: transparent;
    color: #999;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: #e0e0e0;
    background: #37373d;
}

.tab-btn.active {
    color: #fff;
    border-bottom-color: #0e639c;
    background: #252526;
}

.tab-content {
    display: none;
    overflow-y: auto;
    flex: 1;
    padding: 16px;
}

.tab-content.active {
    display: block;
}

/* SECTIONS */
.section {
    margin-bottom: 20px;
}

.section-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #999;
    text-transform: uppercase;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.input-label {
    display: block;
    font-size: 12px;
    color: #ccc;
    margin-bottom: 6px;
}

/* INPUTS */
input[type="text"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 8px 10px;
    background: #3c3c3c;
    border: 1px solid #3e3e42;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 13px;
    font-family: inherit;
    transition: border-color 0.2s;
}

input[type="text"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: #0e639c;
}

textarea {
    resize: vertical;
    min-height: 80px;
}

.select-input {
    cursor: pointer;
    min-height: 36px;
}

/* COLOR INPUTS */
input[type="color"] {
    width: 100%;
    height: 40px;
    border: 1px solid #3e3e42;
    border-radius: 4px;
    background: #3c3c3c;
    cursor: pointer;
}

.color-input-large {
    height: 60px;
}

.color-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.color-input-group {
    display: flex;
    flex-direction: column;
}

/* RANGE SLIDER */
.slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #3c3c3c;
    outline: none;
    -webkit-appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #0e639c;
    cursor: pointer;
}

.slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #0e639c;
    cursor: pointer;
    border: none;
}

/* CHECKBOXES */
.checkbox-group {
    display: flex;
    gap: 16px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    color: #ccc;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.layer-toggle {
    padding: 10px 0;
    border-bottom: 1px solid #3e3e42;
}

.layer-toggle:last-child {
    border-bottom: none;
}

/* Alignment buttons */
.alignment-group {
    display: flex;
    gap: 4px;
    background: #3c3c3c;
    border-radius: 4px;
    padding: 4px;
}

.alignment-btn {
    flex: 1;
    padding: 8px;
    border: none;
    background: transparent;
    color: #ccc;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.alignment-btn:hover {
    background: #505050;
    color: #fff;
}

.alignment-btn.active {
    background: #0e639c;
    color: #fff;
}

.alignment-btn svg {
    stroke: currentColor;
}

/* TWO COLUMN LAYOUT */
.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* BUTTONS */
.button-row {
    display: flex;
    gap: 8px;
}

.secondary-btn,
.danger-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.secondary-btn {
    background: #3c3c3c;
    color: #e0e0e0;
}

.secondary-btn:hover {
    background: #505050;
}

.danger-btn {
    background: #c72e2e;
    color: #fff;
}

.danger-btn:hover {
    background: #e13838;
}

/* TEXT BOXES */
.textbox {
    position: absolute;
    min-width: 60px;
    min-height: 30px;
    padding: 6px;
    outline: none;
    border: 1px dashed transparent;
    background: transparent;
    cursor: text;
    user-select: text;
    transform-origin: center;
    pointer-events: auto;
}

.textbox-content {
    white-space: pre-wrap;
    word-wrap: break-word;
    pointer-events: auto;
}

.textbox.selected {
    border-color: rgba(14, 99, 156, 0.8);
    box-shadow: 0 0 0 1px rgba(14, 99, 156, 0.4);
}

/* RESIZE HANDLES */
.handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #0e639c;
    border: 2px solid white;
    border-radius: 2px;
    z-index: 20;
    pointer-events: auto;
    display: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.textbox.selected .handle {
    display: block;
}

/* HANDLE POSITIONS */
.handle.nw { 
    top: -6px; 
    left: -6px; 
    cursor: move; 
}

.handle.ne { 
    top: -6px; 
    right: -6px; 
    cursor: nesw-resize; 
}

.handle.se { 
    bottom: -6px; 
    right: -6px; 
    cursor: nwse-resize; 
}

.handle.sw { 
    bottom: -6px; 
    left: -6px; 
    cursor: nesw-resize; 
}

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

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

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

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

/* ROTATE HANDLE */
.rotate-handle {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    width: 14px;
    height: 14px;
    background: #0e639c;
    border: 2px solid white;
    border-radius: 50%;
    cursor: grab;
    z-index: 30;
    pointer-events: auto;
    display: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.textbox.selected .rotate-handle {
    display: block;
}

/* LOADING OVERLAY */
#loadingOverlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
}

.loading-content {
    text-align: center;
    color: #fff;
    max-width: 450px;
    width: 90%;
    padding: 40px;
    background: rgba(45, 45, 48, 0.95);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.loading-spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto 20px;
    border: 4px solid rgba(14, 99, 156, 0.2);
    border-top-color: #0e639c;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-title {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #fff;
}

.loading-subtitle {
    font-size: 14px;
    color: #aaa;
    margin-bottom: 28px;
    min-height: 20px;
}

.progress-bar-container {
    width: 100%;
    height: 12px;
    background: #252528;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 16px;
    border: 1px solid #3e3e42;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #0e639c, #1177bb, #0e639c);
    background-size: 200% 100%;
    border-radius: 6px;
    width: 0%;
    transition: width 0.4s ease-out;
    position: relative;
    animation: shimmer 2s linear infinite;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.progress-bar-shine {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shine 1.5s ease-in-out infinite;
}

@keyframes shine {
    0% { left: -100%; }
    100% { left: 200%; }
}

.loading-percentage {
    font-size: 18px;
    font-weight: 700;
    color: #1177bb;
    font-variant-numeric: tabular-nums;
}

/* HELP MODAL */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: #252526;
    border: 1px solid #3e3e42;
    border-radius: 8px;
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #3e3e42;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: #fff;
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    color: #999;
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.close-btn:hover {
    background: #3e3e42;
    color: #fff;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.help-section {
    margin-bottom: 32px;
}

.help-section:last-child {
    margin-bottom: 0;
}

.help-section h3 {
    font-size: 18px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #0e639c;
}

.help-section p {
    color: #ccc;
    line-height: 1.6;
    margin-bottom: 12px;
}

.help-section ul {
    color: #ccc;
    line-height: 1.8;
    margin-left: 20px;
    margin-bottom: 12px;
}

.help-section ul li {
    margin-bottom: 6px;
}

.help-item {
    margin-bottom: 20px;
}

.help-item:last-child {
    margin-bottom: 0;
}

.help-item h4 {
    font-size: 15px;
    font-weight: 600;
    color: #0e639c;
    margin-bottom: 8px;
}

.help-item p {
    margin-bottom: 8px;
}

.help-item ul {
    margin-top: 8px;
}

.help-section strong {
    color: #fff;
    font-weight: 600;
}

/* SCROLLBARS */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #1e1e1e;
}

::-webkit-scrollbar-thumb {
    background: #505050;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #606060;
}

.textbox.selected,
#brushCursor {
    will-change: transform;
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===================================
   RESPONSIVE DESIGN
   =================================== */

/* 1024px */
@media (max-width: 1024px) {
    #leftSidebar {
        width: 180px;
    }
    
    #rightSidebar {
        width: 280px;
    }
    #leftSidebar .collapse-btn {
        left: 180px;
    }
    
    #rightSidebar .collapse-btn {
        right: 280px;
    }
    #topBar {
        padding: 0 12px;
    }
    
    .top-left h1 {
        font-size: 16px;
    }
    
    .tool-btn {
        padding: 6px 10px;
        font-size: 12px;
    }
}

/* Tablet portrait and below */
@media (max-width: 768px) {
    #leftSidebar {
        margin-left: -200px;
    }
    
    #rightSidebar {
        margin-right: -300px;
    }
    
    #leftSidebar.collapsed {
        margin-left: -200px;
    }
    
    #leftSidebar:not(.collapsed) {
        margin-left: 0;
        z-index: 1500;
        box-shadow: 2px 0 10px rgba(0,0,0,0.5);
    }
    
    #rightSidebar.collapsed {
        margin-right: -300px;
    }
    
    #rightSidebar:not(.collapsed) {
        margin-right: 0;
        z-index: 1500;
        box-shadow: -2px 0 10px rgba(0,0,0,0.5);
    }
    
    #leftSidebar .collapse-btn {
        left: 0px;
    }
    
    #leftSidebar:not(.collapsed) .collapse-btn {
        left: 200px;
    }
    
    #rightSidebar .collapse-btn {
        right: 0px;
    }
    
    #rightSidebar:not(.collapsed) .collapse-btn {
        right: 300px;
    }
    
    #topBar {
        height: 56px;
        padding: 0 8px;
        flex-wrap: wrap;
    }
    
    #mainContent {
        top: 56px;
    }
    
    .top-left h1 {
        font-size: 14px;
    }
    
    .tool-btn span {
        display: none;
    }
    
    .tool-btn {
        padding: 8px;
        gap: 0;
    }
    
    .primary-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .page-buttons {
        grid-template-columns: 1fr;
    }
    
    .icon-btn {
        width: 40px;
        height: 40px;
    }
    
    .handle {
        width: 14px;
        height: 14px;
    }
    
    .rotate-handle {
        width: 18px;
        height: 18px;
    }
    
    .tab-btn {
        padding: 14px 12px;
        font-size: 12px;
    }
    
    .modal-content {
        max-width: 95%;
        max-height: 85vh;
    }
    
    .modal-body {
        padding: 16px;
    }
    
    .help-section h3 {
        font-size: 16px;
    }

    .floating-help-btn {
        width: 48px;
        height: 48px;
        bottom: 16px;
        right: 16px;
    }
}

/* Mobile portrait */
@media (max-width: 480px) {
    #leftSidebar {
        width: 100%;
        max-width: 280px;
    }
    
    #rightSidebar {
        width: 100%;
        max-width: 320px;
    }
    
    #leftSidebar:not(.collapsed) .collapse-btn {
        left: calc(100% - 25px);
        max-width: 280px;
    }
    
    #rightSidebar:not(.collapsed) .collapse-btn {
        right: calc(100% - 25px);
        max-width: 320px;
    }
    
    #topBar {
        height: 52px;
        gap: 4px;
    }
    
    #mainContent {
        top: 52px;
    }
    
    .top-left h1 {
        font-size: 13px;
    }
	
    .top-center {
        gap: 6px;
    }
    
    .tool-group {
        padding: 2px;
        gap: 2px;
    }
    
    .icon-btn {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
    
    /* Stack export dropdown differently */
    .export-dropdown-menu {
        right: 0;
        min-width: 160px;
    }
    
    
    #canvasWrapper {
        margin: 10px;
    }
    
    .sidebar-section {
        padding: 12px;
    }
    
    .sidebar-section h3 {
        font-size: 11px;
        margin-bottom: 8px;
    }
    
    input[type="text"],
    input[type="number"],
    textarea,
    select {
        padding: 6px 8px;
        font-size: 12px;
    }
    
    input[type="color"] {
        height: 36px;
    }
    
    .color-input-large {
        height: 48px;
    }
    
    .two-col {
        grid-template-columns: 1fr;
        gap: 8px;
    }
	
    .tab-content {
        padding: 12px;
    }
    
    .section {
        margin-bottom: 16px;
    }
}

/* Landscape mobile*/
@media (max-height: 500px) and (orientation: landscape) {
    #topBar {
        height: 48px;
    }
    
    #mainContent {
        top: 48px;
    }
    
    .top-left h1 {
        font-size: 12px;
    }
    
    .sidebar-section {
        padding: 8px;
    }
    
    .tab-content {
        padding: 8px;
    }
    
    .modal-content {
        max-height: 90vh;
    }
    
    .modal-body {
        padding: 12px;
    }
}