* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.5;
    font-size: 14px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 15px;
}

.main-content {
    display: flex;
    gap: 15px;
    align-items: flex-start;
}

.control-panel {
    flex: 0 0 250px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 5px;
    height: fit-content;
    overflow-y: auto;
}

.panel-section {
    margin-bottom: 5px;
    padding-bottom: 5px;
    border-bottom: 1px solid #eee;
}

.panel-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.panel-section h2 {
    font-size: 0.9rem;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 5px;
}

.btn {
    width: 100%;
    padding: 6px 10px;
    margin-bottom: 5px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s;
}

.btn:last-child {
    margin-bottom: 0;
}

.btn:hover:not(:disabled) {
    background-color: #2980b9;
}

.btn:disabled {
    background-color: #bdc3c7;
    cursor: not-allowed;
}

.btn.primary {
    background-color: #27ae60;
}

.btn.primary:hover:not(:disabled) {
    background-color: #229954;
}

.mode-btn.active {
    background-color: #27ae60;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.row-group {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.row-group .btn {
    flex: 1;
    margin-bottom: 0;
}

.canvas-area {
    flex: 1;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    display: flex;
    flex-direction: column;
}

.canvas-wrapper {
    position: relative;
    flex: 1;
    min-height: 500px;
    background: #fafafa;
    border: 2px dashed #ddd;
    border-radius: 4px;
    overflow: auto;
}

.canvas-wrapper.drag-over {
    border-color: #3498db;
    background-color: #ecf8ff;
}

.drop-hint {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 300px;
    color: #888;
}

.drop-hint.hidden {
    display: none;
}

.drop-icon {
    font-size: 48px;
    margin-bottom: 10px;
}

.page-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px;
}

.page-grid.hidden {
    display: none;
}

.page-thumbnail {
    width: 120px;
    border: 2px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    cursor: grab;
    background: white;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.page-thumbnail:hover {
    border-color: #3498db;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.page-thumbnail.selected {
    border-color: #27ae60;
    box-shadow: 0 0 0 3px rgba(39, 174, 96, 0.3);
}

.page-thumbnail.dragging {
    opacity: 0.5;
    transform: scale(1.05);
}

.page-thumbnail.drag-over {
    border-color: #e74c3c;
    transform: scale(1.02);
}

.page-thumbnail canvas {
    width: 100%;
    height: auto;
    display: block;
}

.page-thumbnail .page-label {
    text-align: center;
    padding: 4px;
    font-size: 0.7rem;
    background: #f5f5f5;
    border-top: 1px solid #ddd;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.thumbnail-placeholder {
    width: 100%;
    height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f0f0;
    color: #888;
    font-size: 0.8rem;
}

.status {
    margin-top: 10px;
    padding: 8px;
    background-color: #ecf0f1;
    border-radius: 4px;
    font-size: 0.8rem;
    color: #555;
    min-height: 20px;
}

.input-group {
    margin-bottom: 5px;
}

.input-group label {
    display: block;
    font-size: 0.8rem;
    color: #555;
    margin-bottom: 2px;
}

.input-group input[type="text"] {
    width: 100%;
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.85rem;
}

.input-group input[type="text"]:focus {
    outline: none;
    border-color: #3498db;
}

.hint {
    color: #888;
    font-size: 0.75rem;
}

@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }

    .control-panel {
        flex: none;
        width: 100%;
    }

    .canvas-wrapper {
        min-height: 400px;
    }

    .page-thumbnail {
        width: 100px;
    }
}
