*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: #1a1a1a;
    background: #f4f4f4;
    min-height: 100vh;
    display: grid;
    grid-template-columns: 220px 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
        "header header"
        "controls workspace";
}

.app-header {
    grid-area: header;
    padding: 1rem 1.25rem;
    background: #2b3a4a;
    color: #f0f0f0;
}

.app-header h1 {
    margin: 0 0 0.25rem;
    font-size: 1.35rem;
    font-weight: 600;
}

.app-header__hint {
    margin: 0;
    font-size: 0.875rem;
    opacity: 0.85;
}

.controls {
    grid-area: controls;
    padding: 1rem 1.25rem;
    background: #fff;
    border-right: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.control-label {
    font-size: 0.875rem;
    font-weight: 500;
}

.control-group input[type="range"] {
    width: 100%;
}

.control-group input[type="file"] {
    font-size: 0.8125rem;
    max-width: 100%;
}

.controls__note {
    margin: 0;
    font-size: 0.75rem;
    color: #666;
}

.workspace {
    grid-area: workspace;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    padding: 1rem;
    min-height: 0;
    overflow: auto;
}

.panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.panel__title {
    margin: 0;
    padding: 0.65rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    background: #e8e8e8;
    border-bottom: 1px solid #ddd;
}

.panel__body {
    flex: 1;
    position: relative;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
}

.crop-panel cropper-canvas {
    width: 100%;
    height: 400px;
}

.crop-panel.has-image #cropPlaceholder {
    display: none;
}

.output-panel {
    background: #fafafa;
}

.output-panel.has-output #outputPlaceholder {
    display: none;
}

#halftone {
    max-width: 100%;
    max-height: 100%;
    display: none;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.output-panel.has-output #halftone {
    display: block;
}

.placeholder {
    position: absolute;
    margin: 0;
    padding: 1rem;
    text-align: center;
    font-size: 0.875rem;
    color: #888;
    pointer-events: none;
}

@media (max-width: 900px) {
    body {
        grid-template-columns: 1fr;
        grid-template-areas:
            "header"
            "controls"
            "workspace";
    }

    .controls {
        border-right: none;
        border-bottom: 1px solid #ddd;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: flex-end;
    }

    .controls__note {
        flex: 1 1 100%;
    }

    .workspace {
        grid-template-columns: 1fr;
    }
}
