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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #1f1f24;
    color: #f1f1f1;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.controls {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.input-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dimensions {
    display: flex;
    gap: 15px;
    align-items: center;
}

input[type="number"] {
    width: 80px;
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.file-input {
    display: none;
}

button, .upload-btn {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

button:hover, .upload-btn:hover {
    background-color: #0056b3;
}

.controls label:not(.upload-btn),
.dimensions label,
.zoom-control label {
    color: #111;
    font-weight: 400;
}

.upload-btn {
    color: #fff;
}

.zoom-control #zoomValue {
    color: #111;
    font-weight: 400;
}

.export-controls {
    position: relative;
    display: inline-flex;
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.export-controls .export-btn {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.export-toggle {
    background-color: #006ce0;
    color: #fff;
    border: none;
    padding: 0 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.export-toggle:hover,
.export-toggle[aria-expanded="true"] {
    background-color: #0056b3;
}

.toggle-icon {
    font-size: 12px;
    line-height: 1;
}

.export-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    box-shadow: 0 12px 24px rgba(0,0,0,0.15);
    padding: 4px 0;
    min-width: 140px;
    display: none;
    z-index: 5;
}

.export-menu.open {
    display: flex;
    flex-direction: column;
}

.export-option {
    background: transparent;
    color: #333;
    width: 100%;
    text-align: left;
    padding: 8px 14px;
    border: none;
    font-size: 14px;
    cursor: pointer;
    border-radius: 0;
}

.export-option:hover {
    background-color: #f0f4ff;
}

.export-option:disabled {
    color: #aaa;
    cursor: not-allowed;
    background: transparent;
}

.zoom-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.zoom-control input[type="range"] {
    flex: 1 1 auto;
    min-width: 140px;
}

.canvas-container {
    position: relative;
    margin: 0 auto;
    background: #f2f4f7;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.35);
    overflow: hidden;
    width: 100%;
    height: calc(100vh - 200px);
    display: flex;
    justify-content: center;
    align-items: center;
}

#mainCanvas {
    position: absolute;
    cursor: move;
    background-color: #fafbff;
    background-image:
        conic-gradient(
            rgba(255,255,255,0.85) 25%,
            rgba(226,231,240,0.8) 0 50%,
            rgba(255,255,255,0.85) 0 75%,
            rgba(226,231,240,0.8) 0
        );
    background-size: 24px 24px;
}

#cropFrame {
    position: absolute;
    border: 2px solid white;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    z-index: 2;
}

.filename-bar {
    margin-top: 16px;
    background: #fff;
    border-radius: 8px;
    padding: 10px 16px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.filename-logo img {
    display: block;
    max-height: 40px;
    width: auto;
}

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

.filename-label {
    font-weight: 600;
    color: #333;
    white-space: nowrap;
}

.filename-editor {
    display: flex;
    align-items: center;
    border: 1px solid #d0d7de;
    border-radius: 6px;
    padding: 6px 14px;
    background: #fdfdfd;
    width: clamp(320px, 45vw, 520px);
    max-width: 100%;
}

.filename-input {
    border: none;
    outline: none;
    font-size: 15px;
    flex: 1;
    min-width: 260px;
    background: transparent;
    color: #1f2328;
}

.filename-extension {
    font-size: 15px;
    color: #6a737d;
    margin-left: 6px;
}

@media (max-width: 1024px) {
    .controls {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }

    .input-group,
    .dimensions,
    .zoom-control {
        width: 100%;
    }

    .dimensions {
        flex-wrap: wrap;
        gap: 12px;
    }

    .dimensions .input-group {
        flex: 1 1 calc(50% - 12px);
        justify-content: space-between;
    }

    .export-controls {
        width: 100%;
    }

    .export-controls .export-btn,
    .export-controls .export-toggle {
        flex: 1;
    }

    .canvas-container {
        height: 70vh;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 12px;
    }

    .controls {
        padding: 16px;
        gap: 14px;
    }

    .zoom-control {
        flex-wrap: wrap;
        gap: 8px;
    }

    .zoom-control label,
    .zoom-control #zoomValue {
        min-width: fit-content;
    }

    .export-controls {
        display: flex;
        width: 100%;
        box-shadow: none;
    }

    .export-controls .export-btn,
    .export-controls .export-toggle {
        flex: 1;
    }

    .export-menu {
        right: auto;
        left: 0;
    }

    .canvas-container {
        height: 60vh;
    }

    .filename-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .filename-controls {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .filename-editor {
        width: 100%;
    }
}

@media (max-width: 520px) {
    button,
    .upload-btn {
        width: 100%;
        text-align: center;
    }

    .dimensions .input-group {
        flex: 1 1 100%;
    }

    .canvas-container {
        height: 55vh;
    }
}
