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

:root {
    --toolbar-height: 85px; /* match your separator height */
}

body {
    background: #f0f0f0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.toolbar {
    position: fixed;
    z-index: 10;
    height: var(--toolbar-height);
    width: 100%;
    background: white;
    border-bottom: 1px solid #ddd;
    display: flex;
    align-items: center;
    padding-left: 20px;
    padding-right: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.toolbar-center {
    display: flex;
    align-items: center;
    gap: 20px;
    flex: 1;
    justify-content: center;
}

.toolbar-action-right {
    margin-left: auto;
    flex-shrink: 0;
}

.tool-group {
    display: flex;
    gap: 5px;
    align-items: center;
}

.tool-group label {
    font-size: 14px;
    color: #666;
    margin-right: 5px;
}

button {
    padding: 8px 8px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

button:hover {
    background: #f5f5f5;
    border-color: #4a90e2;
}

button.active {
    background: #4a90e2;
    color: white;
    border-color: #4a90e2;
}

/* Tool button style (for pencil, brush, eraser, and shape) */
.tool-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 70px;
    padding: 8px 12px;
}

/* Shape button group */
.shape-button-group {
    position: relative;
    display: inline-flex;
}

#shape-button {
    position: relative;
    border-radius: 4px;
}

.shape-dropdown-indicator {
    position: absolute;
    bottom: 3px;
    right: 4px;
    font-size: 12px;
    color: #666;
    line-height: 1;
    pointer-events: none;
}

button.active .shape-dropdown-indicator {
    color: white;
}



.shape-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
}

.shape-dropdown-menu.show {
    display: flex;
    flex-direction: column;
}

.shape-dropdown-menu button {
    border: none;
    border-radius: 0;
    text-align: left;
    padding: 10px 16px;
    width: 100%;
}

.shape-dropdown-menu button:first-child {
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
}

.shape-dropdown-menu button:last-child {
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
}

.shape-dropdown-menu button:hover {
    background: #f5f5f5;
}

input[type="color"] {
    width: 60px;
    height: 60px;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
}

input[type="number"] {
    width: 60px;
    padding: 8px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    text-align: center;
}

.canvas-container {
    position: fixed;
    top: var(--toolbar-height);  /* push down below toolbar */
    left: 0;
    width: 100vw;
    height: calc(100vh - var(--toolbar-height));  /* remaining height */
    z-index: 0;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

#canvas {
    background: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    cursor: crosshair;
    transform-origin: center center;
    transition: transform 0.1s ease-out;
}

#canvas.panning {
    cursor: grab;
}

#canvas.panning:active {
    cursor: grabbing;
}

.separator {
    height: 85px;
    width: 3px;
    background: #ddd;
}


.size-controls {
    display: flex;
    align-items: center;
    gap: 0; /* Remove gap */
    height: 35px;
}

.size-controls input[type="number"] {
    width: 50px;
    height: 100%;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px 0 0 4px; /* Round only left side */
    border-right: none; /* Remove right border */
    font-size: 14px;
    text-align: center;
}

/* Hide native spin buttons */
.size-controls input[type="number"]::-webkit-inner-spin-button,
.size-controls input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.size-controls input[type="number"] {
    -moz-appearance: textfield; /* Firefox */
}

.px-label {
    font-size: 12px;
    color: #666;
    border: 1px solid #ddd;
    border-left: none;
    border-right: none;
    padding: 0 6px;
    height: 100%;
    display: flex;
    align-items: center;
    background: #f9f9f9;
}

.size-buttons {
    display: flex;
    flex-direction: column;
    gap: 2px;
    height: 100%;
}

.size-btn {
    padding: 0;
    min-width: 24px;
    height: calc(50% - 1px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    line-height: 1;
    border-radius: 0 4px 4px 0; /* Round right side */
}

.size-btn:first-child {
    border-radius: 0 4px 0 0;
    border-bottom: none;
}

.size-btn:last-child {
    border-radius: 0 0 4px 0;
}

.toolbar-action-left {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    padding: 8px 8px;
    font-size: 14px;
}

.toolbar-action-left img {
    width: 50px;
    height: 50px;
}

/* Overlay backdrop */
.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.overlay.show {
    display: flex;
}

/* Overlay panel */
.overlay-panel {
    background: white;
    border-radius: 8px;
    padding: 28px 32px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    min-width: 300px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.overlay-panel h2 {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.overlay-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.overlay-field label {
    font-size: 13px;
    color: #555;
    font-weight: 500;
}

.overlay-field input[type="number"] {
    width: 100%;
    padding: 8px 10px;
    font-size: 14px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-align: left;
}

.overlay-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 4px;
}

.overlay-actions button.primary {
    background: #4a90e2;
    color: white;
    border-color: #4a90e2;
}

.overlay-actions button.primary:hover {
    background: #357abd;
    border-color: #357abd;
}