* {
    box-sizing: border-box;
}

html,
body,
#root {
    min-height: 100%;
    margin: 0;
}

body {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #f6f7fb;
    color: #172033;
}

button,
input {
    font: inherit;
}

.page {
    min-height: 100vh;
    padding: 24px;
}

.header {
    max-width: 1500px;
    margin: 0 auto 24px;
    text-align: center;
}

.header h1 {
    margin: 0;
    font-size: 38px;
    line-height: 1.1;
}

.header p {
    margin: 8px 0;
    color: #5d667a;
}

.status {
    min-height: 24px;
}

.shortcut-row,
.format-row,
.canvas-status {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 14px;
}

.workspace {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 24px;
    max-width: 1500px;
    margin: 0 auto;
}

.panel {
    background: #ffffff;
    border: 1px solid #dde2ee;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(23, 32, 51, 0.08);
}

.toolbar {
    height: fit-content;
    padding: 20px;
}

.toolbar h3,
.toolbar h4 {
    margin: 0 0 12px;
}

.section {
    border-top: 1px solid #e7ebf3;
    margin-top: 18px;
    padding-top: 18px;
}

.tool-button,
.tool-button-active,
.primary-button,
.secondary-button,
.danger-button {
    min-height: 38px;
    border: 1px solid #cbd3e4;
    border-radius: 6px;
    padding: 8px 11px;
    cursor: pointer;
}

.tool-button,
.tool-button-active {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 8px;
    background: #ffffff;
}

.tool-button-active,
.primary-button {
    border-color: #4f46e5;
    background: #4f46e5;
    color: #ffffff;
}

.secondary-button {
    background: #ffffff;
}

.danger-button {
    background: #fff1f2;
    border-color: #fecdd3;
    color: #be123c;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.key,
.badge,
.format {
    border: 1px solid #d3d9e7;
    border-radius: 999px;
    padding: 3px 8px;
    font-size: 12px;
    color: #465168;
    background: #f7f8fc;
}

.badge-active {
    border-color: #4f46e5;
    background: #eef2ff;
    color: #3730a3;
}

.button-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.muted {
    color: #6b7280;
    font-size: 13px;
    text-align: center;
}

.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 14px;
}

.slider {
    display: block;
    width: 100%;
    margin-top: 10px;
}

.actions {
    display: grid;
    gap: 8px;
}

.stats {
    border-top: 1px solid #e7ebf3;
    margin-top: 18px;
    padding-top: 18px;
    display: grid;
    gap: 10px;
}

.stat {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #5d667a;
    font-size: 14px;
}

.canvas-panel {
    padding: 20px;
}

.drop-zone {
    min-height: 420px;
    border: 2px dashed #cbd3e4;
    border-radius: 8px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 8px;
    text-align: center;
    cursor: pointer;
    background: #fbfcff;
}

.drop-zone:hover {
    border-color: #4f46e5;
    background: #f8f8ff;
}

.upload-icon {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: #eef2ff;
    color: #3730a3;
    font-weight: 700;
}

.hidden-input {
    display: none;
}

.canvas-frame {
    width: 100%;
    overflow: hidden;
    border: 1px solid #d7deea;
    border-radius: 8px;
    background: #ffffff;
}

.canvas {
    display: block;
    width: min(1200px, 100%);
    height: auto;
    aspect-ratio: 4 / 3;
    touch-action: none;
}

.cursor-pan {
    cursor: grab;
}

.cursor-draw {
    cursor: crosshair;
}

@media (max-width: 980px) {
    .workspace {
        grid-template-columns: 1fr;
    }

    .header h1 {
        font-size: 30px;
    }
}

@media (max-width: 640px) {
    .page {
        padding: 10px;
    }

    .header {
        margin-bottom: 12px;
    }

    .header h1 {
        font-size: 24px;
    }

    .header p {
        margin: 6px 0;
    }

    .shortcut-row {
        display: none;
    }

    .workspace {
        gap: 12px;
    }

    .toolbar,
    .canvas-panel {
        padding: 12px;
    }

    .toolbar {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    button {
        min-height: 44px;
    }

    .toolbar h3 {
        grid-column: 1 / -1;
    }

    .tool-button,
    .tool-button-active {
        min-height: 48px;
        margin-bottom: 0;
        padding: 6px;
        justify-content: center;
    }

    .tool-button .key,
    .tool-button-active .key {
        display: none;
    }

    .section,
    .stats {
        grid-column: 1 / -1;
        width: 100%;
        margin-top: 4px;
        padding-top: 12px;
    }

    .drop-zone {
        min-height: 260px;
    }
}
